Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 1 | From fef2b892245d5a2f3c68d2e03a6c5f2a40205cf7 Mon Sep 17 00:00:00 2001 |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 2 | From: Steve Shin <jonshin@cisco.com> |
| 3 | Date: Wed, 23 Mar 2016 09:54:54 -0700 |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 4 | Subject: [PATCH 14/22] vmxnet3: support jumbo frames |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | drivers/net/vmxnet3/vmxnet3_ethdev.c | 3 +- |
| 8 | drivers/net/vmxnet3/vmxnet3_ring.h | 2 + |
| 9 | drivers/net/vmxnet3/vmxnet3_rxtx.c | 77 ++++++++++++++++++++++-------------- |
| 10 | 3 files changed, 52 insertions(+), 30 deletions(-) |
| 11 | |
| 12 | diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c |
| 13 | index c363bf6..b78acd4 100644 |
| 14 | --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c |
| 15 | +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c |
| 16 | @@ -425,6 +425,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) |
| 17 | { |
| 18 | struct rte_eth_conf port_conf = dev->data->dev_conf; |
| 19 | struct vmxnet3_hw *hw = dev->data->dev_private; |
| 20 | + uint32_t mtu = dev->data->mtu; |
| 21 | Vmxnet3_DriverShared *shared = hw->shared; |
| 22 | Vmxnet3_DSDevRead *devRead = &shared->devRead; |
| 23 | uint32_t *mac_ptr; |
| 24 | @@ -442,7 +443,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) |
| 25 | devRead->misc.driverInfo.vmxnet3RevSpt = 1; |
| 26 | devRead->misc.driverInfo.uptVerSpt = 1; |
| 27 | |
| 28 | - devRead->misc.mtu = rte_le_to_cpu_32(dev->data->mtu); |
| 29 | + devRead->misc.mtu = rte_le_to_cpu_32(mtu); |
| 30 | devRead->misc.queueDescPA = hw->queueDescPA; |
| 31 | devRead->misc.queueDescLen = hw->queue_desc_len; |
| 32 | devRead->misc.numTxQueues = hw->num_tx_queues; |
| 33 | diff --git a/drivers/net/vmxnet3/vmxnet3_ring.h b/drivers/net/vmxnet3/vmxnet3_ring.h |
| 34 | index 612487e..b1582f8 100644 |
| 35 | --- a/drivers/net/vmxnet3/vmxnet3_ring.h |
| 36 | +++ b/drivers/net/vmxnet3/vmxnet3_ring.h |
| 37 | @@ -171,6 +171,8 @@ typedef struct vmxnet3_rx_queue { |
| 38 | uint32_t qid1; |
| 39 | uint32_t qid2; |
| 40 | Vmxnet3_RxQueueDesc *shared; |
| 41 | + struct rte_mbuf *start_seg; |
| 42 | + struct rte_mbuf *last_seg; |
| 43 | struct vmxnet3_rxq_stats stats; |
| 44 | bool stopped; |
| 45 | uint16_t queue_id; /**< Device RX queue index. */ |
| 46 | diff --git a/drivers/net/vmxnet3/vmxnet3_rxtx.c b/drivers/net/vmxnet3/vmxnet3_rxtx.c |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 47 | index c76b230..59b6db8 100644 |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 48 | --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c |
| 49 | +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c |
| 50 | @@ -547,7 +547,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) |
| 51 | vmxnet3_rx_queue_t *rxq; |
| 52 | Vmxnet3_RxCompDesc *rcd; |
| 53 | vmxnet3_buf_info_t *rbi; |
| 54 | - Vmxnet3_RxDesc *rxd; |
| 55 | struct rte_mbuf *rxm = NULL; |
| 56 | struct vmxnet3_hw *hw; |
| 57 | |
| 58 | @@ -572,37 +571,16 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) |
| 59 | |
| 60 | idx = rcd->rxdIdx; |
| 61 | ring_idx = (uint8_t)((rcd->rqID == rxq->qid1) ? 0 : 1); |
| 62 | - rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; |
| 63 | rbi = rxq->cmd_ring[ring_idx].buf_info + idx; |
| 64 | |
| 65 | - if (unlikely(rcd->sop != 1 || rcd->eop != 1)) { |
| 66 | - rte_pktmbuf_free_seg(rbi->m); |
| 67 | - PMD_RX_LOG(DEBUG, "Packet spread across multiple buffers\n)"); |
| 68 | - goto rcd_done; |
| 69 | - } |
| 70 | - |
| 71 | PMD_RX_LOG(DEBUG, "rxd idx: %d ring idx: %d.", idx, ring_idx); |
| 72 | |
| 73 | + #ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER |
| 74 | + Vmxnet3_RxDesc *rxd |
| 75 | + = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; |
| 76 | VMXNET3_ASSERT(rcd->len <= rxd->len); |
| 77 | VMXNET3_ASSERT(rbi->m); |
| 78 | - |
| 79 | - if (unlikely(rcd->len == 0)) { |
| 80 | - PMD_RX_LOG(DEBUG, "Rx buf was skipped. rxring[%d][%d]\n)", |
| 81 | - ring_idx, idx); |
| 82 | - VMXNET3_ASSERT(rcd->sop && rcd->eop); |
| 83 | - rte_pktmbuf_free_seg(rbi->m); |
| 84 | - goto rcd_done; |
| 85 | - } |
| 86 | - |
| 87 | - /* Assuming a packet is coming in a single packet buffer */ |
| 88 | - if (unlikely(rxd->btype != VMXNET3_RXD_BTYPE_HEAD)) { |
| 89 | - PMD_RX_LOG(DEBUG, |
| 90 | - "Alert : Misbehaving device, incorrect " |
| 91 | - " buffer type used. iPacket dropped."); |
| 92 | - rte_pktmbuf_free_seg(rbi->m); |
| 93 | - goto rcd_done; |
| 94 | - } |
| 95 | - VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD); |
| 96 | + #endif |
| 97 | |
| 98 | /* Get the packet buffer pointer from buf_info */ |
| 99 | rxm = rbi->m; |
| 100 | @@ -615,7 +593,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) |
| 101 | rxq->cmd_ring[ring_idx].next2comp = idx; |
| 102 | |
| 103 | /* For RCD with EOP set, check if there is frame error */ |
| 104 | - if (unlikely(rcd->err)) { |
| 105 | + if (unlikely(rcd->eop && rcd->err)) { |
| 106 | rxq->stats.drop_total++; |
| 107 | rxq->stats.drop_err++; |
| 108 | |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 109 | @@ -642,9 +620,49 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 110 | rxm->vlan_tci = 0; |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 111 | rxm->packet_type = RTE_PTYPE_UNKNOWN; |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 112 | |
| 113 | - vmxnet3_rx_offload(rcd, rxm); |
| 114 | + /* |
| 115 | + * If this is the first buffer of the received packet, |
| 116 | + * set the pointer to the first mbuf of the packet |
| 117 | + * Otherwise, update the total length and the number of segments |
| 118 | + * of the current scattered packet, and update the pointer to |
| 119 | + * the last mbuf of the current packet. |
| 120 | + */ |
| 121 | + if (rcd->sop) { |
| 122 | +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER |
| 123 | + VMXNET3_ASSERT(!rxq->start_seg); |
| 124 | + VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_HEAD); |
| 125 | +#endif |
| 126 | + |
| 127 | + if (unlikely(rcd->len == 0)) { |
| 128 | + PMD_RX_LOG(DEBUG, |
| 129 | + "Rx buf was skipped. rxring[%d][%d])", |
| 130 | + ring_idx, idx); |
| 131 | + rte_pktmbuf_free_seg(rbi->m); |
| 132 | + goto rcd_done; |
| 133 | + } |
| 134 | + |
| 135 | + rxq->start_seg = rxm; |
| 136 | + vmxnet3_rx_offload(rcd, rxm); |
| 137 | + } else { |
| 138 | + struct rte_mbuf *start = rxq->start_seg; |
| 139 | + |
| 140 | +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER |
| 141 | + VMXNET3_ASSERT(rxd->btype == VMXNET3_RXD_BTYPE_BODY); |
| 142 | + VMXNET3_ASSERT(start != NULL); |
| 143 | +#endif |
| 144 | + |
| 145 | + start->pkt_len += rxm->data_len; |
| 146 | + start->nb_segs++; |
| 147 | + |
| 148 | + rxq->last_seg->next = rxm; |
| 149 | + } |
| 150 | + rxq->last_seg = rxm; |
| 151 | + |
| 152 | + if (rcd->eop) { |
| 153 | + rx_pkts[nb_rx++] = rxq->start_seg; |
| 154 | + rxq->start_seg = NULL; |
| 155 | + } |
| 156 | |
| 157 | - rx_pkts[nb_rx++] = rxm; |
| 158 | rcd_done: |
| 159 | rxq->cmd_ring[ring_idx].next2comp = idx; |
| 160 | VMXNET3_INC_RING_IDX_ONLY(rxq->cmd_ring[ring_idx].next2comp, rxq->cmd_ring[ring_idx].size); |
Todd Foggoa | a292c8c | 2016-04-06 09:57:01 -0400 | [diff] [blame] | 161 | @@ -945,6 +963,7 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev) |
John Lo | d90df18 | 2016-03-23 16:42:33 -0400 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | rxq->stopped = FALSE; |
| 165 | + rxq->start_seg = NULL; |
| 166 | } |
| 167 | |
| 168 | for (i = 0; i < dev->data->nb_tx_queues; i++) { |
| 169 | -- |
| 170 | 1.9.1 |
| 171 | |