X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsfc%2Fbase%2Fefx_tx.c;h=5cf3dcd3ac3e7f8b77b34d74f1bbc924eda706d5;hb=168c59cfe42b;hp=f8b9801d166d84985060742fabaf3894c40fedc5;hpb=0ecf255632af515a4607fb905b0f423fe6a000e5;p=dpdk.git diff --git a/drivers/net/sfc/base/efx_tx.c b/drivers/net/sfc/base/efx_tx.c index f8b9801d16..5cf3dcd3ac 100644 --- a/drivers/net/sfc/base/efx_tx.c +++ b/drivers/net/sfc/base/efx_tx.c @@ -297,6 +297,24 @@ efx_tx_fini( enp->en_mod_flags &= ~EFX_MOD_TX; } + __checkReturn size_t +efx_txq_size( + __in const efx_nic_t *enp, + __in unsigned int ndescs) +{ + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); + + return (ndescs * encp->enc_tx_desc_size); +} + + __checkReturn unsigned int +efx_txq_nbufs( + __in const efx_nic_t *enp, + __in unsigned int ndescs) +{ + return (EFX_DIV_ROUND_UP(efx_txq_size(enp, ndescs), EFX_BUF_SIZE)); +} + __checkReturn efx_rc_t efx_tx_qcreate( __in efx_nic_t *enp, @@ -312,6 +330,7 @@ efx_tx_qcreate( { const efx_tx_ops_t *etxop = enp->en_etxop; efx_txq_t *etp; + const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp); efx_rc_t rc; EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC); @@ -320,12 +339,22 @@ efx_tx_qcreate( EFSYS_ASSERT3U(enp->en_tx_qcount + 1, <, enp->en_nic_cfg.enc_txq_limit); + EFSYS_ASSERT(ISP2(encp->enc_txq_max_ndescs)); + EFSYS_ASSERT(ISP2(encp->enc_txq_min_ndescs)); + + if (!ISP2(ndescs) || + ndescs < encp->enc_txq_min_ndescs || + ndescs > encp->enc_txq_max_ndescs) { + rc = EINVAL; + goto fail1; + } + /* Allocate an TXQ object */ EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_txq_t), etp); if (etp == NULL) { rc = ENOMEM; - goto fail1; + goto fail2; } etp->et_magic = EFX_TXQ_MAGIC; @@ -339,16 +368,18 @@ efx_tx_qcreate( if ((rc = etxop->etxo_qcreate(enp, index, label, esmp, ndescs, id, flags, eep, etp, addedp)) != 0) - goto fail2; + goto fail3; enp->en_tx_qcount++; *etpp = etp; return (0); +fail3: + EFSYS_PROBE(fail3); + EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_txq_t), etp); fail2: EFSYS_PROBE(fail2); - EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_txq_t), etp); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc); return (rc); @@ -572,19 +603,10 @@ efx_tx_qdesc_post( { efx_nic_t *enp = etp->et_enp; const efx_tx_ops_t *etxop = enp->en_etxop; - efx_rc_t rc; EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC); - if ((rc = etxop->etxo_qdesc_post(etp, ed, - ndescs, completed, addedp)) != 0) - goto fail1; - - return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - return (rc); + return (etxop->etxo_qdesc_post(etp, ed, ndescs, completed, addedp)); } void @@ -625,6 +647,7 @@ efx_tx_qdesc_tso_create( efx_tx_qdesc_tso2_create( __in efx_txq_t *etp, __in uint16_t ipv4_id, + __in uint16_t outer_ipv4_id, __in uint32_t tcp_seq, __in uint16_t mss, __out_ecount(count) efx_desc_t *edp, @@ -636,7 +659,8 @@ efx_tx_qdesc_tso2_create( EFSYS_ASSERT3U(etp->et_magic, ==, EFX_TXQ_MAGIC); EFSYS_ASSERT(etxop->etxo_qdesc_tso2_create != NULL); - etxop->etxo_qdesc_tso2_create(etp, ipv4_id, tcp_seq, mss, edp, count); + etxop->etxo_qdesc_tso2_create(etp, ipv4_id, outer_ipv4_id, + tcp_seq, mss, edp, count); } void @@ -761,10 +785,9 @@ siena_tx_qpost( { unsigned int added = *addedp; unsigned int i; - int rc = ENOSPC; if (added - completed + ndescs > EFX_TXQ_LIMIT(etp->et_mask + 1)) - goto fail1; + return (ENOSPC); for (i = 0; i < ndescs; i++) { efx_buffer_t *ebp = &eb[i]; @@ -786,11 +809,6 @@ siena_tx_qpost( *addedp = added; return (0); - -fail1: - EFSYS_PROBE1(fail1, efx_rc_t, rc); - - return (rc); } static void @@ -935,32 +953,24 @@ siena_tx_qcreate( (1 << FRF_AZ_TX_DESCQ_LABEL_WIDTH)); EFSYS_ASSERT3U(label, <, EFX_EV_TX_NLABELS); - EFSYS_ASSERT(ISP2(encp->enc_txq_max_ndescs)); - EFX_STATIC_ASSERT(ISP2(EFX_TXQ_MINNDESCS)); - - if (!ISP2(ndescs) || - (ndescs < EFX_TXQ_MINNDESCS) || (ndescs > EFX_EVQ_MAXNEVS)) { - rc = EINVAL; - goto fail1; - } if (index >= encp->enc_txq_limit) { rc = EINVAL; - goto fail2; + goto fail1; } for (size = 0; - (1 << size) <= (int)(encp->enc_txq_max_ndescs / EFX_TXQ_MINNDESCS); + (1U << size) <= encp->enc_txq_max_ndescs / encp->enc_txq_min_ndescs; size++) - if ((1 << size) == (int)(ndescs / EFX_TXQ_MINNDESCS)) + if ((1U << size) == (uint32_t)ndescs / encp->enc_txq_min_ndescs) break; if (id + (1 << size) >= encp->enc_buftbl_limit) { rc = EINVAL; - goto fail3; + goto fail2; } inner_csum = EFX_TXQ_CKSUM_INNER_IPV4 | EFX_TXQ_CKSUM_INNER_TCPUDP; if ((flags & inner_csum) != 0) { rc = EINVAL; - goto fail4; + goto fail3; } /* Set up the new descriptor queue */ @@ -985,8 +995,6 @@ siena_tx_qcreate( return (0); -fail4: - EFSYS_PROBE(fail4); fail3: EFSYS_PROBE(fail3); fail2: