ixgbe: fix whitespace
[dpdk.git] / drivers / net / ixgbe / ixgbe_rxtx.c
index 8d5576b..9e2132b 100644 (file)
@@ -85,7 +85,8 @@
                PKT_TX_VLAN_PKT |                \
                PKT_TX_IP_CKSUM |                \
                PKT_TX_L4_MASK |                 \
-               PKT_TX_TCP_SEG)
+               PKT_TX_TCP_SEG |                 \
+               PKT_TX_OUTER_IP_CKSUM)
 
 static inline struct rte_mbuf *
 rte_rxmbuf_alloc(struct rte_mempool *mp)
@@ -108,7 +109,7 @@ rte_rxmbuf_alloc(struct rte_mempool *mp)
  */
 #define rte_ixgbe_prefetch(p)   rte_prefetch0(p)
 #else
-#define rte_ixgbe_prefetch(p)   do {} while(0)
+#define rte_ixgbe_prefetch(p)   do {} while (0)
 #endif
 
 /*********************************************************************
@@ -126,7 +127,8 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq)
 {
        struct ixgbe_tx_entry *txep;
        uint32_t status;
-       int i;
+       int i, nb_free = 0;
+       struct rte_mbuf *m, *free[RTE_IXGBE_TX_MAX_FREE_BUF_SZ];
 
        /* check DD bit on threshold descriptor */
        status = txq->tx_ring[txq->tx_next_dd].wb.status;
@@ -139,20 +141,27 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq)
         */
        txep = &(txq->sw_ring[txq->tx_next_dd - (txq->tx_rs_thresh - 1)]);
 
-       /* free buffers one at a time */
-       if ((txq->txq_flags & (uint32_t)ETH_TXQ_FLAGS_NOREFCOUNT) != 0) {
-               for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
-                       txep->mbuf->next = NULL;
-                       rte_mempool_put(txep->mbuf->pool, txep->mbuf);
-                       txep->mbuf = NULL;
-               }
-       } else {
-               for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
-                       rte_pktmbuf_free_seg(txep->mbuf);
-                       txep->mbuf = NULL;
+       for (i = 0; i < txq->tx_rs_thresh; ++i, ++txep) {
+               /* free buffers one at a time */
+               m = __rte_pktmbuf_prefree_seg(txep->mbuf);
+               txep->mbuf = NULL;
+
+               if (unlikely(m == NULL))
+                       continue;
+
+               if (nb_free >= RTE_IXGBE_TX_MAX_FREE_BUF_SZ ||
+                   (nb_free > 0 && m->pool != free[0]->pool)) {
+                       rte_mempool_put_bulk(free[0]->pool,
+                                            (void **)free, nb_free);
+                       nb_free = 0;
                }
+
+               free[nb_free++] = m;
        }
 
+       if (nb_free > 0)
+               rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free);
+
        /* buffers were freed, update counters */
        txq->nb_tx_free = (uint16_t)(txq->nb_tx_free + txq->tx_rs_thresh);
        txq->tx_next_dd = (uint16_t)(txq->tx_next_dd + txq->tx_rs_thresh);
@@ -364,9 +373,11 @@ ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
        uint32_t ctx_idx;
        uint32_t vlan_macip_lens;
        union ixgbe_tx_offload tx_offload_mask;
+       uint32_t seqnum_seed = 0;
 
        ctx_idx = txq->ctx_curr;
-       tx_offload_mask.data = 0;
+       tx_offload_mask.data[0] = 0;
+       tx_offload_mask.data[1] = 0;
        type_tucmd_mlhl = 0;
 
        /* Specify which HW CTX to upload. */
@@ -430,18 +441,35 @@ ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
                }
        }
 
+       if (ol_flags & PKT_TX_OUTER_IP_CKSUM) {
+               tx_offload_mask.outer_l2_len |= ~0;
+               tx_offload_mask.outer_l3_len |= ~0;
+               tx_offload_mask.l2_len |= ~0;
+               seqnum_seed |= tx_offload.outer_l3_len
+                              << IXGBE_ADVTXD_OUTER_IPLEN;
+               seqnum_seed |= tx_offload.l2_len
+                              << IXGBE_ADVTXD_TUNNEL_LEN;
+       }
+
        txq->ctx_cache[ctx_idx].flags = ol_flags;
-       txq->ctx_cache[ctx_idx].tx_offload.data  =
-               tx_offload_mask.data & tx_offload.data;
+       txq->ctx_cache[ctx_idx].tx_offload.data[0]  =
+               tx_offload_mask.data[0] & tx_offload.data[0];
+       txq->ctx_cache[ctx_idx].tx_offload.data[1]  =
+               tx_offload_mask.data[1] & tx_offload.data[1];
        txq->ctx_cache[ctx_idx].tx_offload_mask    = tx_offload_mask;
 
        ctx_txd->type_tucmd_mlhl = rte_cpu_to_le_32(type_tucmd_mlhl);
        vlan_macip_lens = tx_offload.l3_len;
-       vlan_macip_lens |= (tx_offload.l2_len << IXGBE_ADVTXD_MACLEN_SHIFT);
+       if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
+               vlan_macip_lens |= (tx_offload.outer_l2_len <<
+                                   IXGBE_ADVTXD_MACLEN_SHIFT);
+       else
+               vlan_macip_lens |= (tx_offload.l2_len <<
+                                   IXGBE_ADVTXD_MACLEN_SHIFT);
        vlan_macip_lens |= ((uint32_t)tx_offload.vlan_tci << IXGBE_ADVTXD_VLAN_SHIFT);
        ctx_txd->vlan_macip_lens = rte_cpu_to_le_32(vlan_macip_lens);
        ctx_txd->mss_l4len_idx   = rte_cpu_to_le_32(mss_l4len_idx);
-       ctx_txd->seqnum_seed     = 0;
+       ctx_txd->seqnum_seed     = seqnum_seed;
 }
 
 /*
@@ -454,16 +482,24 @@ what_advctx_update(struct ixgbe_tx_queue *txq, uint64_t flags,
 {
        /* If match with the current used context */
        if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
-               (txq->ctx_cache[txq->ctx_curr].tx_offload.data ==
-               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data & tx_offload.data)))) {
+               (txq->ctx_cache[txq->ctx_curr].tx_offload.data[0] ==
+               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[0]
+                & tx_offload.data[0])) &&
+               (txq->ctx_cache[txq->ctx_curr].tx_offload.data[1] ==
+               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[1]
+                & tx_offload.data[1])))) {
                        return txq->ctx_curr;
        }
 
        /* What if match with the next context  */
        txq->ctx_curr ^= 1;
        if (likely((txq->ctx_cache[txq->ctx_curr].flags == flags) &&
-               (txq->ctx_cache[txq->ctx_curr].tx_offload.data ==
-               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data & tx_offload.data)))) {
+               (txq->ctx_cache[txq->ctx_curr].tx_offload.data[0] ==
+               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[0]
+                & tx_offload.data[0])) &&
+               (txq->ctx_cache[txq->ctx_curr].tx_offload.data[1] ==
+               (txq->ctx_cache[txq->ctx_curr].tx_offload_mask.data[1]
+                & tx_offload.data[1])))) {
                        return txq->ctx_curr;
        }
 
@@ -492,6 +528,8 @@ tx_desc_ol_flags_to_cmdtype(uint64_t ol_flags)
                cmdtype |= IXGBE_ADVTXD_DCMD_VLE;
        if (ol_flags & PKT_TX_TCP_SEG)
                cmdtype |= IXGBE_ADVTXD_DCMD_TSE;
+       if (ol_flags & PKT_TX_OUTER_IP_CKSUM)
+               cmdtype |= (1 << IXGBE_ADVTXD_OUTERIPCS_SHIFT);
        return cmdtype;
 }
 
@@ -588,8 +626,10 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        uint64_t tx_ol_req;
        uint32_t ctx = 0;
        uint32_t new_ctx;
-       union ixgbe_tx_offload tx_offload = {0};
+       union ixgbe_tx_offload tx_offload;
 
+       tx_offload.data[0] = 0;
+       tx_offload.data[1] = 0;
        txq = tx_queue;
        sw_ring = txq->sw_ring;
        txr     = txq->tx_ring;
@@ -623,6 +663,8 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                        tx_offload.l4_len = tx_pkt->l4_len;
                        tx_offload.vlan_tci = tx_pkt->vlan_tci;
                        tx_offload.tso_segsz = tx_pkt->tso_segsz;
+                       tx_offload.outer_l2_len = tx_pkt->outer_l2_len;
+                       tx_offload.outer_l3_len = tx_pkt->outer_l3_len;
 
                        /* If new context need be built or reuse the exist ctx. */
                        ctx = what_advctx_update(txq, tx_ol_req,
@@ -2867,7 +2909,7 @@ ixgbe_vmdq_dcb_configure(struct rte_eth_dev *dev)
                pbsize = (uint16_t)(NIC_RX_BUFFER_SIZE / nb_tcs);
                break;
        }
-       for (i = 0 ; i < nb_tcs; i++) {
+       for (i = 0; i < nb_tcs; i++) {
                uint32_t rxpbsize = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(i));
                rxpbsize &= (~(0x3FF << IXGBE_RXPBSIZE_SHIFT));
                /* clear 10 bits. */
@@ -2913,7 +2955,7 @@ ixgbe_vmdq_dcb_configure(struct rte_eth_dev *dev)
 
        /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
        vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
-       vlanctrl |= IXGBE_VLNCTRL_VFE ; /* enable vlan filters */
+       vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
        IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
 
        /* VFTA - enable all vlan filters */
@@ -3170,7 +3212,7 @@ ixgbe_dcb_rx_hw_config(struct ixgbe_hw *hw,
 
        /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
        vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
-       vlanctrl |= IXGBE_VLNCTRL_VFE ; /* enable vlan filters */
+       vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
        IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
 
        /* VFTA - enable all vlan filters */
@@ -3310,7 +3352,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
        nb_tcs = dcb_config->num_tcs.pfc_tcs;
        /* Unpack map */
        ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
-       if(nb_tcs == ETH_4_TCS) {
+       if (nb_tcs == ETH_4_TCS) {
                /* Avoid un-configured priority mapping to TC0 */
                uint8_t j = 4;
                uint8_t mask = 0xFF;
@@ -3346,11 +3388,11 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
                break;
        }
 
-       if(config_dcb_rx) {
+       if (config_dcb_rx) {
                /* Set RX buffer size */
                pbsize = (uint16_t)(rx_buffer_size / nb_tcs);
                uint32_t rxpbsize = pbsize << IXGBE_RXPBSIZE_SHIFT;
-               for (i = 0 ; i < nb_tcs; i++) {
+               for (i = 0; i < nb_tcs; i++) {
                        IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), rxpbsize);
                }
                /* zero alloc all unused TCs */
@@ -3358,7 +3400,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
                        IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(i), 0);
                }
        }
-       if(config_dcb_tx) {
+       if (config_dcb_tx) {
                /* Only support an equally distributed Tx packet buffer strategy. */
                uint32_t txpktsize = IXGBE_TXPBSIZE_MAX / nb_tcs;
                uint32_t txpbthresh = (txpktsize / DCB_TX_PB) - IXGBE_TXPKT_SIZE_MAX;
@@ -3379,7 +3421,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
        ixgbe_dcb_calculate_tc_credits_cee(hw, dcb_config,max_frame,
                                IXGBE_DCB_RX_CONFIG);
 
-       if(config_dcb_rx) {
+       if (config_dcb_rx) {
                /* Unpack CEE standard containers */
                ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_RX_CONFIG, refill);
                ixgbe_dcb_unpack_max_cee(dcb_config, max);
@@ -3389,7 +3431,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
                ixgbe_dcb_hw_arbite_rx_config(hw,refill,max,bwgid,tsa,map);
        }
 
-       if(config_dcb_tx) {
+       if (config_dcb_tx) {
                /* Unpack CEE standard containers */
                ixgbe_dcb_unpack_refill_cee(dcb_config, IXGBE_DCB_TX_CONFIG, refill);
                ixgbe_dcb_unpack_max_cee(dcb_config, max);
@@ -3403,7 +3445,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
        ixgbe_dcb_config_tc_stats_82599(hw, dcb_config);
 
        /* Check if the PFC is supported */
-       if(dev->data->dev_conf.dcb_capability_en & ETH_DCB_PFC_SUPPORT) {
+       if (dev->data->dev_conf.dcb_capability_en & ETH_DCB_PFC_SUPPORT) {
                pbsize = (uint16_t)(rx_buffer_size / nb_tcs);
                for (i = 0; i < nb_tcs; i++) {
                        /*
@@ -3417,7 +3459,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
                        tc->pfc = ixgbe_dcb_pfc_enabled;
                }
                ixgbe_dcb_unpack_pfc_cee(dcb_config, map, &pfc_en);
-               if(dcb_config->num_tcs.pfc_tcs == ETH_4_TCS)
+               if (dcb_config->num_tcs.pfc_tcs == ETH_4_TCS)
                        pfc_en &= 0x0F;
                ret = ixgbe_dcb_config_pfc(hw, pfc_en, map);
        }
@@ -3492,7 +3534,7 @@ ixgbe_vmdq_rx_hw_configure(struct rte_eth_dev *dev)
 
        /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
        vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
-       vlanctrl |= IXGBE_VLNCTRL_VFE ; /* enable vlan filters */
+       vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
        IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
 
        /* VFTA - enable all vlan filters */