vmxnet3: multisegment and bugfixes
v3 cover vmxnet3: multisegment and bugfixes
From: Stephen Hemminger <[email protected]>
Revised version of earlier patches.
Incorporate the small packet optimization
Add more cleanups
Stephen Hemminger (10):
vmxnet3: fix link state handling
vmxnet3: enable VLAN filtering
vmxnet3: remove mtu check
vmxnet3: cleanup txq stats
vmxnet3: add support for multi-segment transmit
vmxnet3: support RSS and refactor offload
vmxnet3: support jumbo frames
vmxnet3: get rid of DEBUG ifdefs
vmxnet3: add check for jumbo segment
vmxnet3: remove excess inlining
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 162 +++++++++++--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h | 11 +- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 20 +- lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 360 ++++++++++++++++---------------- 4 files changed, 333 insertions(+), 220 deletions(-)
Signature · 1 line
2.1.4
PATCH v3 1/10 vmxnet3: fix link state handling
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
The Intel version of VMXNET3 driver does not handle link state properly. The VMXNET3 API returns 1 if connected and 0 if disconnected. Also need to return correct value to indicate state change.
--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 54 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +39 -15
@@ -149,9 +149,36 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size,* - On success, zero. * - On failure, negative value. */ -static inline int -rte_vmxnet3_dev_atomic_write_link_status (struct rte_eth_dev *dev, -struct rte_eth_link *link) + +static int +vmxnet3_dev_atomic_read_link_status (struct rte_eth_dev *dev, +struct rte_eth_link *link) +{ +struct rte_eth_link *dst = link; +struct rte_eth_link *src = &(dev->data->dev_link); + +if (rte_atomic64_cmpset ((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) ==0 ) +return -1 ; + +return 0 ; +} + +/** +* Atomically writes the link status information into global +* structure rte_eth_dev. +* +* @param dev +* - Pointer to the structure rte_eth_dev to write to. +* - Pointer to the buffer to be saved with the link status. +* +* @return +* - On success, zero. +* - On failure, negative value. +*/ +static int +vmxnet3_dev_atomic_write_link_status (struct rte_eth_dev *dev, +struct rte_eth_link *link) {struct rte_eth_link *dst = &(dev->data->dev_link);struct rte_eth_link *src = link;
@@ -384,6 +411,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt =1 ; devRead->misc.driverInfo.uptVerSpt =1 ; + devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.mtu = hw->cur_mtu;
@@ -570,7 +598,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)/* Clear recorded link status */ memset (&link,0 ,sizeof (link)); -rte_vmxnet3_dev_atomic_write_link_status (dev, &link); +vmxnet3_dev_atomic_write_link_status (dev, &link); }/*
@@ -653,28 +681,24 @@ static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wait_to_complete) {struct vmxnet3_hw *hw = dev->data->dev_private; -struct rte_eth_link link; +struct rte_eth_link old, link;uint32_t ret; +memset (&link,0 ,sizeof (link)); +vmxnet3_dev_atomic_read_link_status (dev, &old); +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD ,VMXNET3_CMD_GET_LINK ); ret =VMXNET3_READ_BAR1_REG (hw,VMXNET3_REG_CMD ); -if (!ret) { -PMD_INIT_LOG (ERR ,"Link Status Negative : %s()" , __func__); -return -1 ; - } -if (ret &0x1 ) { link.link_status =1 ; link.link_duplex =ETH_LINK_FULL_DUPLEX ; link.link_speed =ETH_LINK_SPEED_10000 ; - -rte_vmxnet3_dev_atomic_write_link_status (dev, &link); - -return 0 ; } -return -1 ; +vmxnet3_dev_atomic_write_link_status (dev, &link); + +return (old.link_status == link.link_status) ?-1 :0 ; }/* Updating rxmode through Vmxnet3_DriverShared structure in adapter */
Signature · 1 line
2.1.4
PATCH v3 2/10 vmxnet3: enable VLAN filtering
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
Support the VLAN filter functionality of the VMXNET3 interface.
--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 105 +++++++++++++++++++++++++++++--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h | 4 +- lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 31 +--------- 3 files changed, 102 insertions(+), 38 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +96 -9
@@ -87,6 +87,12 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);static void vmxnet3_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info); +static int vmxnet3_dev_vlan_filter_set (struct rte_eth_dev *dev, +uint16_t vid,int on); +static void vmxnet3_dev_vlan_offload_set (struct rte_eth_dev *dev,int mask); +static void vmxnet3_dev_vlan_offload_set_clear (struct rte_eth_dev *dev, +int mask,int clear); +#if PROCESS_SYS_EVENTS ==1 static void vmxnet3_process_events (struct vmxnet3_hw *);#endif
@@ -113,6 +119,8 @@ static struct eth_dev_ops vmxnet3_eth_dev_ops = { .link_update = vmxnet3_dev_link_update, .stats_get = vmxnet3_dev_stats_get, .dev_infos_get = vmxnet3_dev_info_get, + .vlan_filter_set = vmxnet3_dev_vlan_filter_set, + .vlan_offload_set = vmxnet3_dev_vlan_offload_set, .rx_queue_setup = vmxnet3_dev_rx_queue_setup, .rx_queue_release = vmxnet3_dev_rx_queue_release, .tx_queue_setup = vmxnet3_dev_tx_queue_setup,
@@ -398,7 +406,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)Vmxnet3_DSDevRead *devRead = &shared->devRead;uint32_t *mac_ptr;uint32_t val, i; -int ret; +int ret, mask; shared->magic =VMXNET3_REV1_MAGIC ; devRead->misc.driverInfo.version =VMXNET3_DRIVER_VERSION_NUM ;
@@ -470,9 +478,6 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)if (dev->data->dev_conf.rxmode.hw_ip_checksum) devRead->misc.uptFeatures |=VMXNET3_F_RXCSUM ; -if (dev->data->dev_conf.rxmode.hw_vlan_strip) - devRead->misc.uptFeatures |=VMXNET3_F_RXVLAN ; -if (port_conf.rxmode.mq_mode ==ETH_MQ_RX_RSS ) { ret =vmxnet3_rss_configure (dev);if (ret !=VMXNET3_SUCCESS )
@@ -484,11 +489,14 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->rssConfDesc.confPA = hw->rss_confPA; } -if (dev->data->dev_conf.rxmode.hw_vlan_filter) { - ret =vmxnet3_vlan_configure (dev); -if (ret !=VMXNET3_SUCCESS ) -return ret; - } + mask =0 ; +if (dev->data->dev_conf.rxmode.hw_vlan_strip) + mask |=ETH_VLAN_STRIP_MASK ; + +if (dev->data->dev_conf.rxmode.hw_vlan_filter) + mask |=ETH_VLAN_FILTER_MASK ; + +vmxnet3_dev_vlan_offload_set_clear (dev, mask,1 ); PMD_INIT_LOG(DEBUG, "Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x",
@@ -720,8 +728,13 @@ static void vmxnet3_dev_promiscuous_enable(struct rte_eth_dev *dev) {struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; +memset (vf_table,0 ,VMXNET3_VFT_TABLE_SIZE );vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_PROMISC ,1 ); + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); }/* Promiscuous supported only if Vmxnet3_DriverShared is initialized in adapter */
@@ -729,8 +742,12 @@ static void vmxnet3_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; +memcpy (vf_table, hw->shadow_vfta,VMXNET3_VFT_TABLE_SIZE );vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_PROMISC ,0 ); +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); }/* Allmulticast supported only if Vmxnet3_DriverShared is initialized in adapter */
@@ -751,6 +768,76 @@ vmxnet3_dev_allmulticast_disable(struct rte_eth_dev *dev)vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_ALL_MULTI ,0 ); } +/* Enable/disable filter on vlan */ +static int +vmxnet3_dev_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vid,int on) +{ +struct vmxnet3_hw *hw = dev->data->dev_private; +struct Vmxnet3_RxFilterConf *rxConf = &hw->shared->devRead.rxFilterConf; +uint32_t *vf_table = rxConf->vfTable; + +/* save state for restore */ +if (on) +VMXNET3_SET_VFTABLE_ENTRY (hw->shadow_vfta, vid); +else +VMXNET3_CLEAR_VFTABLE_ENTRY (hw->shadow_vfta, vid); + +/* don't change active filter if in promiscious mode */ +if (rxConf->rxMode &VMXNET3_RXM_PROMISC ) +return 0 ; + +/* set in hardware */ +if (on) +VMXNET3_SET_VFTABLE_ENTRY (vf_table, vid); +else +VMXNET3_CLEAR_VFTABLE_ENTRY (vf_table, vid); + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); +return 0 ; +} + +static void +vmxnet3_dev_vlan_offload_set_clear (struct rte_eth_dev *dev, +int mask,int clear) +{ +struct vmxnet3_hw *hw = dev->data->dev_private; +Vmxnet3_DSDevRead *devRead = &hw->shared->devRead; +uint32_t *vf_table = devRead->rxFilterConf.vfTable; + +if (mask Ð_VLAN_STRIP_MASK ) + devRead->misc.uptFeatures |=UPT1_F_RXVLAN ; +else + devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN ; + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_FEATURE ); + +if (mask Ð_VLAN_FILTER_MASK ) { +if (clear) { +memset (hw->shadow_vfta,0 , +VMXNET3_VFT_TABLE_SIZE ); +/* allow untagged pkts */ +VMXNET3_SET_VFTABLE_ENTRY (hw->shadow_vfta,0 ); + } +memcpy (vf_table, hw->shadow_vfta,VMXNET3_VFT_TABLE_SIZE ); + }else { +/* allow any pkts -- no filtering */ +if (clear) +memset (hw->shadow_vfta,0xff ,VMXNET3_VFT_TABLE_SIZE ); +memset (vf_table,0xff ,VMXNET3_VFT_TABLE_SIZE ); + } + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); +} + +static void +vmxnet3_dev_vlan_offload_set (struct rte_eth_dev *dev,int mask) +{ +vmxnet3_dev_vlan_offload_set_clear (dev, mask,0 ); +} +#if PROCESS_SYS_EVENTS ==1 static void vmxnet3_process_events (struct vmxnet3_hw *hw)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h +3 -1
@@ -121,8 +121,11 @@ struct vmxnet3_hw {VMXNET3_RSSConf *rss_conf;uint64_t rss_confPA;vmxnet3_mf_table_t *mf_table; +uint32_t shadow_vfta[VMXNET3_VFT_SIZE ]; }; +#define VMXNET3_VFT_TABLE_SIZE (VMXNET3_VFT_SIZE * sizeof(uint32_t)) +#define VMXNET3_GET_ADDR_LO (reg) ((uint32_t)(reg))#define VMXNET3_GET_ADDR_HI (reg) ((uint32_t)(((uint64_t)(reg)) >> 32))
@@ -173,7 +176,6 @@ int vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,int vmxnet3_dev_rxtx_init (struct rte_eth_dev *dev);int vmxnet3_rss_configure (struct rte_eth_dev *dev); -int vmxnet3_vlan_configure (struct rte_eth_dev *dev);uint16_t vmxnet3_recv_pkts (void *rx_queue,struct rte_mbuf **rx_pkts,uint16_t nb_pkts);
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +3 -28
@@ -738,9 +738,9 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,return -EINVAL ; } -if ((tx_conf->txq_flags Ð_TXQ_FLAGS_NOOFFLOADS ) != -ETH_TXQ_FLAGS_NOOFFLOADS ) { -PMD_INIT_LOG (ERR ,"TX not support offload function yet" ); +if ((tx_conf->txq_flags Ð_TXQ_FLAGS_NOXSUMS ) != +ETH_TXQ_FLAGS_NOXSUMS ) { +PMD_INIT_LOG (ERR ,"TX no support for checksum offload yet" );return -EINVAL ; }
@@ -1045,28 +1045,3 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)return VMXNET3_SUCCESS ; } - -/* -* Configure VLAN Filter feature -*/ -int -vmxnet3_vlan_configure (struct rte_eth_dev *dev) -{ -uint8_t i; -struct vmxnet3_hw *hw = dev->data->dev_private; -uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; - -PMD_INIT_FUNC_TRACE (); - -/* Verify if this tag is already set */ -for (i =0 ; i <VMXNET3_VFT_SIZE ; i++) { -/* Filter all vlan tags out by default */ - vf_table[i] =0 ; -/* To-Do: Provide another routine in dev_ops for user config */ - -PMD_INIT_LOG (DEBUG ,"Registering VLAN portid: %" PRIu8" tag %u" , - dev->data->port_id, vf_table[i]); - } - -return VMXNET3_SUCCESS ; -}
Signature · 1 line
2.1.4
PATCH v3 3/10 vmxnet3: remove mtu check
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
Remove check for packets greater than MTU. No other driver does this, it should be handled at higher layer
--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 2 -- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h | 1 - lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 10 ---------- 3 files changed, 13 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +0 -2
@@ -246,7 +246,6 @@ eth_vmxnet3_dev_init(__attribute__((unused)) struct eth_driver *eth_drv, hw->num_rx_queues =1 ; hw->num_tx_queues =1 ; - hw->cur_mtu =ETHER_MTU ; hw->bufs_per_pkt =1 ;/* Check h/w version compatibility with driver. */
@@ -422,7 +421,6 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; - devRead->misc.mtu = hw->cur_mtu; devRead->misc.numTxQueues = hw->num_tx_queues; devRead->misc.numRxQueues = hw->num_rx_queues;
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h +0 -1
@@ -107,7 +107,6 @@ struct vmxnet3_hw {uint8_t num_tx_queues;uint8_t num_rx_queues;uint8_t bufs_per_pkt; -uint16_t cur_mtu;Vmxnet3_TxQueueDesc *tqd_start;/* start address of all tx queue desc */ Vmxnet3_RxQueueDesc *rqd_start;/* start address of all rx queue desc */
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +0 -10
@@ -369,16 +369,6 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,continue ; } -/* Needs to minus ether header len */ -if (txm->data_len > (hw->cur_mtu +ETHER_HDR_LEN )) { -PMD_TX_LOG (DEBUG ,"Packet data_len higher than MTU" ); -rte_pktmbuf_free (tx_pkts[nb_tx]); - txq->stats.drop_total++; - - nb_tx++; -continue ; - } - txd = (Vmxnet3_TxDesc *)(txq->cmd_ring.base + txq->cmd_ring.next2fill);if (rte_pktmbuf_pkt_len (txm) <=VMXNET3_HDR_COPY_SIZE ) {struct Vmxnet3_TxDataDesc *tdd;
Signature · 1 line
2.1.4
PATCH v3 4/10 vmxnet3: cleanup txq stats
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
There are several stats here which are never set, and have no way to be displayed. Assume in future xstats could be used.
--- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ring.h +6 -10
@@ -121,16 +121,12 @@ vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring) }struct vmxnet3_txq_stats { -uint64_t drop_total;/* # of pkts dropped by the driver, the -* counters below track droppings due to -* different reasons -*/ -uint64_t drop_oversized; -uint64_t drop_hdr_inspect_err; -uint64_t drop_tso; -uint64_t deferred; -uint64_t tx_ring_full; -uint64_t linearized;/* # of pkts linearized */ +uint64_t drop_total;/* # of pkts dropped by the driver, +* the counters below track droppings due to +* different reasons +*/ +uint64_t drop_tso; +uint64_t tx_ring_full; }; typedef struct vmxnet3_tx_ctx {
Signature · 1 line
2.1.4
PATCH v3 5/10 vmxnet3: add support for multi-segment transmit
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
Change sending loop to support multi-segment mbufs. The VMXNET3 api has start-of-packet and end-packet flags, so it is not hard to send multi-segment mbuf's.
Also, update descriptor in 32 bit value rather than toggling bitfields which is slower and error prone.
Based on code in earlier driver, and the Linux kernel driver.
Add a compiler barrier to make sure that update of earlier descriptor are completed prior to update of generation bit on start of packet.
---
v3 -- add back in small packet optimization
lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 1 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 155 +++++++++++++++++----------------- 2 files changed, 79 insertions(+), 77 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ring.h +1 -0
@@ -125,6 +125,7 @@ struct vmxnet3_txq_stats {* the counters below track droppings due to * different reasons */ +uint64_t drop_too_many_segs;uint64_t drop_tso;uint64_t tx_ring_full; };
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +78 -77
204 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 6/10 vmxnet3: support RSS and refactor offload
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
Refactor the logic to compute receive offload flags to a simpler function. Andd add support for putting RSS flow hash into packet.
--- lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 69 ++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 29 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +40 -29
@@ -521,6 +521,43 @@ vmxnet3_post_rx_bufs(vmxnet3_rx_queue_t *rxq, uint8_t ring_id)return i; } + +/* Receive side checksum and other offloads */ +static void +vmxnet3_rx_offload (const Vmxnet3_RxCompDesc *rcd,struct rte_mbuf *rxm) +{ +/* Check for hardware stripped VLAN tag */ +if (rcd->ts) { + rxm->ol_flags |=PKT_RX_VLAN_PKT ; + rxm->vlan_tci =rte_le_to_cpu_16 ((uint16_t )rcd->tci); + } + +/* Check for RSS */ +if (rcd->rssType !=VMXNET3_RCD_RSS_TYPE_NONE ) { + rxm->ol_flags |=PKT_RX_RSS_HASH ; + rxm->hash.rss = rcd->rssHash; + } + +/* Check packet type, checksum errors, etc. Only support IPv4 for now. */ +if (rcd->v4) { + struct ether_hdr *eth = rte_pktmbuf_mtod(rxm, struct ether_hdr *); +struct ipv4_hdr *ip = (struct ipv4_hdr *)(eth +1 ); + +if (((ip->version_ihl &0xf ) <<2 ) > (int )sizeof (struct ipv4_hdr )) + rxm->ol_flags |=PKT_RX_IPV4_HDR_EXT ; +else + rxm->ol_flags |=PKT_RX_IPV4_HDR ; + +if (!rcd->cnc) { +if (!rcd->ipc) + rxm->ol_flags |=PKT_RX_IP_CKSUM_BAD ; + +if ((rcd->tcp || rcd->udp) && !rcd->tuc) + rxm->ol_flags |=PKT_RX_L4_CKSUM_BAD ; + } + } +} +/* * Process the Rx Completion Ring of given vmxnet3_rx_queue * for nb_pkts burst and return the number of packets received
@@ -621,17 +658,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) goto rcd_done; } -/* Check for hardware stripped VLAN tag */ -if (rcd->ts) { -PMD_RX_LOG (DEBUG ,"Received packet with vlan ID: %d." , - rcd->tci); - rxm->ol_flags =PKT_RX_VLAN_PKT ; -/* Copy vlan tag in packet buffer */ - rxm->vlan_tci =rte_le_to_cpu_16 ((uint16_t )rcd->tci); - }else { - rxm->ol_flags =0 ; - rxm->vlan_tci =0 ; - }/* Initialize newly received packet buffer */ rxm->port = rxq->port_id;
@@ -640,25 +666,10 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->pkt_len = (uint16_t )rcd->len; rxm->data_len = (uint16_t )rcd->len; rxm->data_off =RTE_PKTMBUF_HEADROOM ; + rxm->ol_flags =0 ; + rxm->vlan_tci =0 ; -/* Check packet type, checksum errors, etc. Only support IPv4 for now. */ -if (rcd->v4) { - struct ether_hdr *eth = rte_pktmbuf_mtod(rxm, struct ether_hdr *); -struct ipv4_hdr *ip = (struct ipv4_hdr *)(eth +1 ); - -if (((ip->version_ihl &0xf ) <<2 ) > (int )sizeof (struct ipv4_hdr )) - rxm->ol_flags |=PKT_RX_IPV4_HDR_EXT ; -else - rxm->ol_flags |=PKT_RX_IPV4_HDR ; - -if (!rcd->cnc) { -if (!rcd->ipc) - rxm->ol_flags |=PKT_RX_IP_CKSUM_BAD ; - -if ((rcd->tcp || rcd->udp) && !rcd->tuc) - rxm->ol_flags |=PKT_RX_L4_CKSUM_BAD ; - } - } +vmxnet3_rx_offload (rcd, rxm); rx_pkts[nb_rx++] = rxm; rcd_done:
Signature · 1 line
2.1.4
PATCH v3 7/10 vmxnet3: support jumbo frames
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
Add support for linking multi-segment buffers together to handle Jumbo packets.
--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 3 +- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 2 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 76 ++++++++++++++++++++------------- 3 files changed, 50 insertions(+), 31 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +2 -1
@@ -401,6 +401,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) {struct rte_eth_conf port_conf = dev->data->dev_conf;struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t mtu = dev->data->mtu;Vmxnet3_DriverShared *shared = hw->shared;Vmxnet3_DSDevRead *devRead = &shared->devRead;uint32_t *mac_ptr;
@@ -418,7 +419,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt =1 ; devRead->misc.driverInfo.uptVerSpt =1 ; - devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); + devRead->misc.mtu =rte_le_to_cpu_32 (mtu); devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.numTxQueues = hw->num_tx_queues;
lib/librte_pmd_vmxnet3/vmxnet3_ring.h +2 -0
@@ -171,6 +171,8 @@ typedef struct vmxnet3_rx_queue {uint32_t qid1;uint32_t qid2;Vmxnet3_RxQueueDesc *shared; +struct rte_mbuf *start_seg; +struct rte_mbuf *last_seg;struct vmxnet3_rxq_stats stats;bool stopped;uint16_t queue_id;/**< Device RX queue index. */
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +46 -30
117 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v3 8/10 vmxnet3: get rid of DEBUG ifdefs
In reply to a message not in the archiveBy defining macro as a stub it is possible to get rid of #ifdef's in the actual code. Always evaluate the argument (even in the stub) so that there are no extra unused variable errors.
--- lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h | 6 ++++-- lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 13 ++----------- 2 files changed, 6 insertions(+), 13 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h +4 -2
@@ -35,9 +35,11 @@#define _VMXNET3_ETHDEV_H_#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -#define VMXNET3_ASSERT (x) do { \ - if (!(x)) rte_panic("VMXNET3: x"); \ +#define VMXNET3_ASSERT (x) do { \ + if (unlikely(!(x))) rte_panic("VMXNET3: %s\n", #x); \ } while(0) +#else +#define VMXNET3_ASSERT (x) do { (void)(x); } while (0)#endif #define VMXNET3_MAX_MAC_ADDRS 1
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +2 -11
@@ -307,9 +307,7 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)while (tcd->gen == comp_ring->gen) {/* Release cmd_ring descriptor and free mbuf */ -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (txq->cmd_ring.base[tcd->txdIdx].txd.eop ==1 ); -#endif while (txq->cmd_ring.next2comp != tcd->txdIdx) { mbuf = txq->cmd_ring.buf_info[txq->cmd_ring.next2comp].m;
@@ -570,6 +568,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)uint8_t ring_idx;vmxnet3_rx_queue_t *rxq;Vmxnet3_RxCompDesc *rcd; +Vmxnet3_RxDesc *rxd;vmxnet3_buf_info_t *rbi;struct rte_mbuf *rxm =NULL ;struct vmxnet3_hw *hw;
@@ -596,16 +595,12 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) idx = rcd->rxdIdx; ring_idx = (uint8_t )((rcd->rqID == rxq->qid1) ?0 :1 ); rbi = rxq->cmd_ring[ring_idx].buf_info + idx; - + rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;PMD_RX_LOG (DEBUG ,"rxd idx: %d ring idx: %d." , idx, ring_idx); -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -Vmxnet3_RxDesc *rxd - = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;VMXNET3_ASSERT (rcd->len <= rxd->len);VMXNET3_ASSERT (rbi->m); -#endif /* Get the packet buffer pointer from buf_info */ rxm = rbi->m;
@@ -652,10 +647,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)* the last mbuf of the current packet. */ if (rcd->sop) { -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (!rxq->start_seg);VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); -#endif if (unlikely (rcd->len ==0 )) { PMD_RX_LOG(DEBUG,
@@ -670,10 +663,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) }else {struct rte_mbuf *start = rxq->start_seg; -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_BODY );VMXNET3_ASSERT (start !=NULL ); -#endif start->pkt_len += rxm->data_len; start->nb_segs++;
Signature · 1 line
2.1.4
PATCH v3 9/10 vmxnet3: add check for jumbo segment
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
It is possible that some rogue application might pass a segment larger than 16K to the vmxnet3 transmit routine. In which case just drop it and increment counter.
--- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 1 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
lib/librte_pmd_vmxnet3/vmxnet3_ring.h +1 -0
@@ -126,6 +126,7 @@ struct vmxnet3_txq_stats {* different reasons */ uint64_t drop_too_many_segs; +uint64_t drop_too_big;uint64_t drop_tso;uint64_t tx_ring_full; };
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +18 -0
@@ -327,6 +327,17 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)PMD_TX_LOG (DEBUG ,"Processed %d tx comps & command descs." , completed); } +static inline int +vmxnet3_seg_too_big (const struct rte_mbuf *m) +{ +do { +if (m->data_len >VMXNET3_MAX_TX_BUF_SIZE ) +return 1 ; + }while ((m = m->next) !=NULL ); + +return 0 ; +} +uint16_t vmxnet3_xmit_pkts (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts)
@@ -353,6 +364,13 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* Is this packet execessively fragmented, then drop */ if (unlikely (txm->nb_segs >VMXNET3_MAX_TXD_PER_PKT )) { ++txq->stats.drop_too_many_segs; + goto drop; + } + +/* Check for case of monster segment */ +if (unlikely (vmxnet3_seg_too_big (txm))) { + ++txq->stats.drop_too_big; + drop: ++txq->stats.drop_total;rte_pktmbuf_free (txm); ++nb_tx;
Signature · 1 line
2.1.4
PATCH v3 10/10 vmxnet3: remove excess inlining
In reply to a message not in the archiveFrom: Stephen Hemminger <[email protected]>
No reason to inline large functions. Compiler will decide already based on optimization level.
Also register array should be const.
--- lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +4 -6
@@ -84,10 +84,8 @@#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) -static uint32_t rxprod_reg[2 ] = {VMXNET3_REG_RXPROD ,VMXNET3_REG_RXPROD2 }; +static const uint32_t rxprod_reg[2 ] = {VMXNET3_REG_RXPROD ,VMXNET3_REG_RXPROD2 }; -static inline int vmxnet3_post_rx_bufs (vmxnet3_rx_queue_t * ,uint8_t ); -static inline void vmxnet3_tq_tx_complete (vmxnet3_tx_queue_t *);#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER_NOT_USED static void vmxnet3_rxq_dump (struct vmxnet3_rx_queue *);static void vmxnet3_txq_dump (struct vmxnet3_tx_queue *);
@@ -157,7 +155,7 @@ vmxnet3_txq_dump(struct vmxnet3_tx_queue *txq) }#endif -static inline void +static void vmxnet3_cmd_ring_release_mbufs (vmxnet3_cmd_ring_t *ring) {while (ring->next2comp != ring->next2fill) {
@@ -296,7 +294,7 @@ vmxnet3_dev_clear_queues(struct rte_eth_dev *dev) } } -static inline void +static void vmxnet3_tq_tx_complete (vmxnet3_tx_queue_t *txq) {int completed =0 ;
@@ -472,7 +470,7 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,* only for LRO. * */ -static inline int +static int vmxnet3_post_rx_bufs (vmxnet3_rx_queue_t *rxq,uint8_t ring_id) {int err =0 ;
Signature · 1 line
2.1.4
Re: [PATCH v3 01/10] vmxnet3: fix link state handling
In reply to a message not in the archiveHi Stephen,
Have you considered supporting LSC interrupts in vmxnet3?
--
Thanks,
Robert
Quoted 116 lines
From: Stephen Hemminger <[email protected]>
The Intel version of VMXNET3 driver does not handle link state properly. The VMXNET3 API returns 1 if connected and 0 if disconnected. Also need to return correct value to indicate state change.
Signed-off-by Stephen Hemminger <[email protected]>Acked-by Yong Wang <[email protected]>---
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c| 54
++++++++++++++++++++++++---------1 file changed, 39 insertions(+), 15 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +30
-3@@ -149,9 +149,36 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_tsize, * - On success, zero. * - On failure, negative value. */ -static inline int -rte_vmxnet3_dev_atomic_write_link_status (struct rte_eth_dev *dev, -struct rte_eth_link *link) + +static int +vmxnet3_dev_atomic_read_link_status (struct rte_eth_dev *dev, +struct rte_eth_link *link) +{ +struct rte_eth_link *dst = link; +struct rte_eth_link *src = &(dev->data->dev_link); + +if (rte_atomic64_cmpset ((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) ==0 ) +return -1 ; + +return 0 ; +} + +/** +* Atomically writes the link status information into global +* structure rte_eth_dev. +* +* @param dev +* - Pointer to the structure rte_eth_dev to write to. +* - Pointer to the buffer to be saved with the link status. +* +* @return +* - On success, zero. +* - On failure, negative value. +*/ +static int +vmxnet3_dev_atomic_write_link_status (struct rte_eth_dev *dev, +struct rte_eth_link *link) {struct rte_eth_link *dst = &(dev->data->dev_link);struct rte_eth_link *src = link;lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +9
-12@@ -384,6 +411,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt =1 ; devRead->misc.driverInfo.uptVerSpt =1 ; + devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.mtu = hw->cur_mtu;@@ -570,7 +598,7 @@ vmxnet3_dev_stop(struct rte_eth_dev *dev)/* Clear recorded link status */ memset (&link,0 ,sizeof (link)); -rte_vmxnet3_dev_atomic_write_link_status (dev, &link); +vmxnet3_dev_atomic_write_link_status (dev, &link); }/* @@ -653,28 +681,24 @@ static int vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wait_to_complete) {struct vmxnet3_hw *hw = dev->data->dev_private; -struct rte_eth_link link; +struct rte_eth_link old, link;uint32_t ret; +memset (&link,0 ,sizeof (link)); +vmxnet3_dev_atomic_read_link_status (dev, &old); +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD ,VMXNET3_CMD_GET_LINK ); ret =VMXNET3_READ_BAR1_REG (hw,VMXNET3_REG_CMD ); -if (!ret) { -PMD_INIT_LOG (ERR ,"Link Status Negative : %s()" , __func__); -return -1 ; - } -if (ret &0x1 ) { link.link_status =1 ; link.link_duplex =ETH_LINK_FULL_DUPLEX ; link.link_speed =ETH_LINK_SPEED_10000 ; - -rte_vmxnet3_dev_atomic_write_link_status (dev, &link); - -return 0 ; } -return -1 ; +vmxnet3_dev_atomic_write_link_status (dev, &link); + +return (old.link_status == link.link_status) ?-1 :0 ; }/* Updating rxmode through
Vmxnet3_DriverSharedstructure in adapter */Signature · 1 line
2.1.4
Yong Wang
Acked-byRe: [PATCH v3 02/10] vmxnet3: enable VLAN filtering
In reply to a message not in the archiveQuoted 5 lines · Stephen Hemminger
From: Stephen Hemminger <[email protected]>
Support the VLAN filter functionality of the VMXNET3 interface.
Signed-off-by Stephen Hemminger <[email protected]>
Quoted 259 lines
---
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c| 105
+++++++++++++++++++++++++++++---lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h| 4 +-lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c| 31 +---------3 files changed, 102 insertions(+), 38 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +6
-0@@ -87,6 +87,12 @@ static void vmxnet3_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats);static void vmxnet3_dev_info_get (struct rte_eth_dev *dev,struct rte_eth_dev_info *dev_info); +static int vmxnet3_dev_vlan_filter_set (struct rte_eth_dev *dev, +uint16_t vid,int on); +static void vmxnet3_dev_vlan_offload_set (struct rte_eth_dev *dev,int mask); +static void vmxnet3_dev_vlan_offload_set_clear (struct rte_eth_dev *dev, +int mask,int clear); +#if PROCESS_SYS_EVENTS ==1 static void
vmxnet3_process_events(struct vmxnet3_hw *); #endiflib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +16
-9@@ -113,6 +119,8 @@ static struct eth_dev_ops vmxnet3_eth_dev_ops = { .link_update = vmxnet3_dev_link_update, .stats_get = vmxnet3_dev_stats_get, .dev_infos_get = vmxnet3_dev_info_get, + .vlan_filter_set = vmxnet3_dev_vlan_filter_set, + .vlan_offload_set = vmxnet3_dev_vlan_offload_set, .rx_queue_setup = vmxnet3_dev_rx_queue_setup, .rx_queue_release = vmxnet3_dev_rx_queue_release, .tx_queue_setup = vmxnet3_dev_tx_queue_setup,@@ -398,7 +406,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)Vmxnet3_DSDevRead *devRead = &shared->devRead;uint32_t *mac_ptr;uint32_t val, i; -int ret; +int ret, mask; shared->magic =VMXNET3_REV1_MAGIC ; devRead->misc.driverInfo.version =VMXNET3_DRIVER_VERSION_NUM ;@@ -470,9 +478,6 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev)if (dev->data->dev_conf.rxmode.hw_ip_checksum) devRead->misc.uptFeatures |=VMXNET3_F_RXCSUM ; -if (dev->data->dev_conf.rxmode.hw_vlan_strip) - devRead->misc.uptFeatures |=VMXNET3_F_RXVLAN ; -if (port_conf.rxmode.mq_mode ==ETH_MQ_RX_RSS ) { ret =vmxnet3_rss_configure (dev);if (ret !=VMXNET3_SUCCESS )@@ -484,11 +489,14 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->rssConfDesc.confPA = hw->rss_confPA; } -if (dev->data->dev_conf.rxmode.hw_vlan_filter) { - ret =vmxnet3_vlan_configure (dev); -if (ret !=VMXNET3_SUCCESS ) -return ret; - } + mask =0 ; +if (dev->data->dev_conf.rxmode.hw_vlan_strip) + mask |=ETH_VLAN_STRIP_MASK ; + +if (dev->data->dev_conf.rxmode.hw_vlan_filter) + mask |=ETH_VLAN_FILTER_MASK ; + +vmxnet3_dev_vlan_offload_set_clear (dev, mask,1 ); PMD_INIT_LOG(DEBUG, "Writing MAC Address : %02x:%02x:%02x:%02x:%02x:%02x",@@ -720,8 +728,13 @@ static void vmxnet3_dev_promiscuous_enable(struct rte_eth_dev *dev) {struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; +memset (vf_table,0 ,VMXNET3_VFT_TABLE_SIZE );vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_PROMISC ,1 ); + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); }/* Promiscuous supported only if Vmxnet3_DriverShared is initialized in adapter */
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +4
-0@@ -729,8 +742,12 @@ static void vmxnet3_dev_promiscuous_disable(struct rte_eth_dev *dev) {struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; +memcpy (vf_table, hw->shadow_vfta,VMXNET3_VFT_TABLE_SIZE );vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_PROMISC ,0 ); +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); }/* Allmulticast supported only if Vmxnet3_DriverShared is initialized in adapter */
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +70
-0@@ -751,6 +768,76 @@ vmxnet3_dev_allmulticast_disable(struct rte_eth_dev *dev)vmxnet3_dev_set_rxmode (hw,VMXNET3_RXM_ALL_MULTI ,0 ); } +/* Enable/disable filter on vlan */ +static int +vmxnet3_dev_vlan_filter_set (struct rte_eth_dev *dev,uint16_t vid,int on) +{ +struct vmxnet3_hw *hw = dev->data->dev_private; +struct Vmxnet3_RxFilterConf *rxConf = &hw->shared->devRead.rxFilterConf; +uint32_t *vf_table = rxConf->vfTable; + +/* save state for restore */ +if (on) +VMXNET3_SET_VFTABLE_ENTRY (hw->shadow_vfta, vid); +else +VMXNET3_CLEAR_VFTABLE_ENTRY (hw->shadow_vfta, vid); + +/* don't change active filter if in promiscious mode */ +if (rxConf->rxMode &VMXNET3_RXM_PROMISC ) +return 0 ; + +/* set in hardware */ +if (on) +VMXNET3_SET_VFTABLE_ENTRY (vf_table, vid); +else +VMXNET3_CLEAR_VFTABLE_ENTRY (vf_table, vid); + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); +return 0 ; +} + +static void +vmxnet3_dev_vlan_offload_set_clear (struct rte_eth_dev *dev, +int mask,int clear) +{ +struct vmxnet3_hw *hw = dev->data->dev_private; +Vmxnet3_DSDevRead *devRead = &hw->shared->devRead; +uint32_t *vf_table = devRead->rxFilterConf.vfTable; + +if (mask Ð_VLAN_STRIP_MASK ) + devRead->misc.uptFeatures |=UPT1_F_RXVLAN ; +else + devRead->misc.uptFeatures &= ~UPT1_F_RXVLAN ; + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_FEATURE ); + +if (mask Ð_VLAN_FILTER_MASK ) { +if (clear) { +memset (hw->shadow_vfta,0 , +VMXNET3_VFT_TABLE_SIZE ); +/* allow untagged pkts */ +VMXNET3_SET_VFTABLE_ENTRY (hw->shadow_vfta,0 ); + } +memcpy (vf_table, hw->shadow_vfta,VMXNET3_VFT_TABLE_SIZE ); + }else { +/* allow any pkts -- no filtering */ +if (clear) +memset (hw->shadow_vfta,0xff ,VMXNET3_VFT_TABLE_SIZE ); +memset (vf_table,0xff ,VMXNET3_VFT_TABLE_SIZE ); + } + +VMXNET3_WRITE_BAR1_REG (hw,VMXNET3_REG_CMD , +VMXNET3_CMD_UPDATE_VLAN_FILTERS ); +} + +static void +vmxnet3_dev_vlan_offload_set (struct rte_eth_dev *dev,int mask) +{ +vmxnet3_dev_vlan_offload_set_clear (dev, mask,0 ); +} +#if PROCESS_SYS_EVENTS ==1 static void
vmxnet3_process_events(struct vmxnet3_hw *hw)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h +3
-1@@ -121,8 +121,11 @@ struct vmxnet3_hw {VMXNET3_RSSConf *rss_conf;uint64_t rss_confPA;vmxnet3_mf_table_t *mf_table; +uint32_t shadow_vfta[VMXNET3_VFT_SIZE ]; }; +#define VMXNET3_VFT_TABLE_SIZE (VMXNET3_VFT_SIZE * sizeof(uint32_t)) +#define VMXNET3_GET_ADDR_LO (reg) ((uint32_t)(reg))#define VMXNET3_GET_ADDR_HI (reg) ((uint32_t)(((uint64_t)(reg)) >> 32))@@ -173,7 +176,6 @@ int vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id, int vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev);int vmxnet3_rss_configure (struct rte_eth_dev *dev); -int vmxnet3_vlan_configure (struct rte_eth_dev *dev); uint16_t vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,uint16_t nb_pkts);lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +3
-28@@ -738,9 +738,9 @@ vmxnet3_dev_tx_queue_setup(struct rte_eth_dev *dev,return -EINVAL ; } -if ((tx_conf->txq_flags Ð_TXQ_FLAGS_NOOFFLOADS ) != -ETH_TXQ_FLAGS_NOOFFLOADS ) { -PMD_INIT_LOG (ERR ,"TX not support offload function yet" ); +if ((tx_conf->txq_flags Ð_TXQ_FLAGS_NOXSUMS ) != +ETH_TXQ_FLAGS_NOXSUMS ) { +PMD_INIT_LOG (ERR ,"TX no support for checksum offload yet" );return -EINVAL ; }@@ -1045,28 +1045,3 @@ vmxnet3_rss_configure(struct rte_eth_dev *dev)return VMXNET3_SUCCESS ; } - -/* -* Configure VLAN Filter feature -*/ -int -vmxnet3_vlan_configure (struct rte_eth_dev *dev) -{ -uint8_t i; -struct vmxnet3_hw *hw = dev->data->dev_private; -uint32_t *vf_table = hw->shared->devRead.rxFilterConf.vfTable; - -PMD_INIT_FUNC_TRACE (); - -/* Verify if this tag is already set */ -for (i =0 ; i <VMXNET3_VFT_SIZE ; i++) { -/* Filter all vlan tags out by default */ - vf_table[i] =0 ; -/* To-Do: Provide another routine in dev_ops for user config */ - -PMD_INIT_LOG (DEBUG ,"Registering VLAN portid: %" PRIu8" tag %u" , - dev->data->port_id, vf_table[i]); - } - -return VMXNET3_SUCCESS ; -}Signature · 1 line
2.1.4
Yong Wang
Acked-byRe: [PATCH v3 08/10] vmxnet3: get rid of DEBUG ifdefs
In reply to a message not in the archiveQuoted 5 lines · Stephen Hemminger
By defining macro as a stub it is possible to get rid of #ifdef's in the actual code. Always evaluate the argument (even in the stub) so that there are no extra unused variable errors.
Signed-off-by Stephen Hemminger <[email protected]>
Quoted 94 lines
---
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h| 6 ++++--lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c| 13 ++-----------2 files changed, 6 insertions(+), 13 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.h +4
-2@@ -35,9 +35,11 @@#define _VMXNET3_ETHDEV_H_#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -#define VMXNET3_ASSERT (x) do { \ - if (!(x)) rte_panic("VMXNET3: x"); \ +#define VMXNET3_ASSERT (x) do { \ + if (unlikely(!(x))) rte_panic("VMXNET3: %s\n", #x); \ } while(0) +#else +#define VMXNET3_ASSERT (x) do { (void)(x); } while (0)#endif #define VMXNET3_MAX_MAC_ADDRS 1lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-2@@ -307,9 +307,7 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)while (tcd->gen == comp_ring->gen) {/* Release cmd_ring descriptor and free mbuf */ -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (txq->cmd_ring.base[tcd->txdIdx].txd.eop ==1 ); -#endif while (txq->cmd_ring.next2comp != tcd->txdIdx) { mbuf = txq->cmd_ring.buf_info[txq->cmd_ring.next2comp].m;@@ -570,6 +568,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)uint8_t ring_idx;vmxnet3_rx_queue_t *rxq;Vmxnet3_RxCompDesc *rcd; +Vmxnet3_RxDesc *rxd;vmxnet3_buf_info_t *rbi;struct rte_mbuf *rxm =NULL ;struct vmxnet3_hw *hw;lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-5@@ -596,16 +595,12 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) idx = rcd->rxdIdx; ring_idx = (uint8_t )((rcd->rqID == rxq->qid1) ?0 :1 ); rbi = rxq->cmd_ring[ring_idx].buf_info + idx; - + rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;PMD_RX_LOG (DEBUG ,"rxd idx: %d ring idx: %d." , idx, ring_idx); -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -Vmxnet3_RxDesc *rxd - = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;VMXNET3_ASSERT (rcd->len <= rxd->len);VMXNET3_ASSERT (rbi->m); -#endif /* Get the packet buffer pointer from buf_info */ rxm = rbi->m;lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +0
-2@@ -652,10 +647,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf**rx_pkts, uint16_t nb_pkts) * the last mbuf of the current packet. */ if (rcd->sop) { -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (!rxq->start_seg);VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); -#endif if (unlikely (rcd->len ==0 )) {PMD_RX_LOG(DEBUG,
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +0
-2@@ -670,10 +663,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) } else {struct rte_mbuf *start = rxq->start_seg; -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_BODY );VMXNET3_ASSERT (start !=NULL ); -#endif start->pkt_len += rxm->data_len;start->nb_segs++;Signature · 1 line
2.1.4
Yong Wang
Acked-byRe: [PATCH v3 09/10] vmxnet3: add check for jumbo segment
In reply to a message not in the archiveQuoted 7 lines · Stephen Hemminger
From: Stephen Hemminger <[email protected]>
It is possible that some rogue application might pass a segment larger than 16K to the vmxnet3 transmit routine. In which case just drop it and increment counter.
Signed-off-by Stephen Hemminger <[email protected]>
One minor comment below. Otherwise looks good to me.
Quoted 24 lines
---
lib/librte_pmd_vmxnet3/vmxnet3_ring.h| 1 +lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c| 18 ++++++++++++++++++2 files changed, 19 insertions(+)lib/librte_pmd_vmxnet3/vmxnet3_ring.h +1
-0@@ -126,6 +126,7 @@ struct vmxnet3_txq_stats {* different reasons */ uint64_t drop_too_many_segs; +uint64_t drop_too_big;uint64_t drop_tso;uint64_t tx_ring_full; };lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +0
-0
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq) · line 336
Quoted 10 lines
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +7
-0@@ -327,6 +327,17 @@ vmxnet3_tq_tx_complete(vmxnet3_tx_queue_t *txq)PMD_TX_LOG (DEBUG ,"Processed %d tx comps & command descs." , completed); } +static inline int +vmxnet3_seg_too_big (const struct rte_mbuf *m) +{ +do { +if (m->data_len >VMXNET3_MAX_TX_BUF_SIZE ) +return 1 ; + }while ((m = m->next) !=NULL );
nit: extra space after "while”.
Quoted 25 lines
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +4
-0+ +return 0 ; +} +
uint16_t
vmxnet3_xmit_pkts(void*tx_queue, structrte_mbuf**tx_pkts,uint16_t nb_pkts)lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +7
-0@@ -353,6 +364,13 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,/* Is this packet execessively fragmented, then drop */ if (unlikely(txm->nb_segs > VMXNET3_MAX_TXD_PER_PKT)) { ++txq->stats.drop_too_many_segs; + goto drop; + } + +/* Check for case of monster segment */ +if (unlikely (vmxnet3_seg_too_big (txm))) { + ++txq->stats.drop_too_big; + drop: ++txq->stats.drop_total;rte_pktmbuf_free (txm);++nb_tx;Signature · 1 line
2.1.4
Yong Wang
Acked-byRe: [PATCH v3 10/10] vmxnet3: remove excess inlining
In reply to a message not in the archiveQuoted 8 lines · Stephen Hemminger
From: Stephen Hemminger <[email protected]>
No reason to inline large functions. Compiler will decide already based on optimization level.
Also register array should be const.
Signed-off-by Stephen Hemminger <[email protected]>
One comment below.
Quoted 33 lines
---
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c| 10 ++++------1 file changed, 4 insertions(+), 6 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-3@@ -84,10 +84,8 @@#define RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb) \ (uint64_t) ((mb)->buf_physaddr + RTE_PKTMBUF_HEADROOM) -static uint32_t rxprod_reg[2 ] = {VMXNET3_REG_RXPROD , VMXNET3_REG_RXPROD2}; +static const uint32_t rxprod_reg[2 ] = {VMXNET3_REG_RXPROD ,VMXNET3_REG_RXPROD2 }; -static inline int vmxnet3_post_rx_bufs (vmxnet3_rx_queue_t * ,uint8_t ); -static inline void vmxnet3_tq_tx_complete (vmxnet3_tx_queue_t *);#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER_NOT_USED static void
vmxnet3_rxq_dump(struct vmxnet3_rx_queue *); static voidvmxnet3_txq_dump(struct vmxnet3_tx_queue *);lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-1@@ -157,7 +155,7 @@ vmxnet3_txq_dump(struct vmxnet3_tx_queue *txq) }#endif -static inline void +static void vmxnet3_cmd_ring_release_mbufs (vmxnet3_cmd_ring_t *ring) {while (ring->next2comp != ring->next2fill) {
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c vmxnet3_dev_clear_queues(struct rte_eth_dev *dev) · line 298
Quoted 6 lines
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-1@@ -296,7 +294,7 @@ vmxnet3_dev_clear_queues(struct rte_eth_dev *dev) } } -static inline void +static void vmxnet3_tq_tx_complete (vmxnet3_tx_queue_t *txq)
Since there is only one caller of this routine, inlining it should be fine. But I have no problem with letting the compiler decide (which probably will inline it anyway for this particular case).
Quoted 15 lines
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-1{int completed =0 ;@@ -472,7 +470,7 @@ vmxnet3_xmit_pkts(void *tx_queue, struct rte_mbuf**tx_pkts, * only for LRO. * */ -static inline int +static int vmxnet3_post_rx_bufs (vmxnet3_rx_queue_t *rxq,uint8_t ring_id) {int err = 0;Signature · 1 line
2.1.4
Re: [PATCH v3 10/10] vmxnet3: remove excess inlining
In reply to a message not in the archiveQuoted 3 lines · On Fri, 6 Mar 2015 23:54:23 +0000 Yong Wang…
Since there is only one caller of this routine, inlining it should be fine. But I have no problem with letting the compiler decide (which probably will inline it anyway for this particular case).
Sometimes compiler will not inline because of register pressure issues especially on 32 bit where there aren't enough registers.
Re: [PATCH v3 01/10] vmxnet3: fix link state handling
In reply to a message not in the archiveQuoted 7 lines · Robert
Hi Stephen,
Have you considered supporting LSC interrupts in vmxnet3?
--
Thanks,
Robert
I tried implementing it but it is not possible since the VMXNET3 device API does not have an interrupt mask. Therefore there is no way to get Link State interrupts but not get an interrupt for every packet received.
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
In reply to a message not in the archiveQuoted 27 lines · Stephen Hemminger
From: Stephen Hemminger <[email protected]>
Add support for linking multi-segment buffers together to handle Jumbo packets.
Signed-off-by Stephen Hemminger <[email protected]>---
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 3 +- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 2 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 76 ++++++++++++++++++++------------- 3 files changed, 50 insertions(+), 31 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +1
-0@@ -401,6 +401,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) {struct rte_eth_conf port_conf = dev->data->dev_conf;struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t mtu = dev->data->mtu;Vmxnet3_DriverShared *shared = hw->shared;Vmxnet3_DSDevRead *devRead = &shared->devRead;uint32_t *mac_ptr;
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) · line 422
Quoted 5 lines
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +1
-1@@ -418,7 +419,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt =1 ; devRead->misc.driverInfo.uptVerSpt =1 ; - devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); + devRead->misc.mtu =rte_le_to_cpu_32 (mtu);
I didn’t see where mtu is used to calculate how many rx descriptors will be needed for each packet. Furthermore, as pointed out by the following code comments, the device requires the first rx buffer of a packet be of type VMXNET3_RXD_BTYPE_HEAD with the remaining buffers of type VMXNET3_RXD_BTYPE_NODY. This needs to be taken care of when populating rx rings in vmxnet3_post_rx_bufs(). Currently we don’t do this because no scatter-rx is supported and only one descriptor is needed for a packet (thus all types should be HEAD). Otherwise, the device will complain with error returned. For the 2nd rx ring, type needs to be BODY for all descriptors still.
Related to this, could you share what tests have been done to cover these new features?
static intvmxnet3_post_rx_bufs(vmxnet3_rx_queue_t *rxq, uint8_t ring_id)
{
int err = 0;
uint32_t i = 0, val = 0;
struct vmxnet3_cmd_ring *ring = &rxq->cmd_ring[ring_id];
if (ring_id == 0) {
/* Usually: One HEAD type buf per packet
* val = (ring->next2fill % rxq->hw->bufs_per_pkt) ?
* VMXNET3_RXD_BTYPE_BODY : VMXNET3_RXD_BTYPE_HEAD;
*/
/* We use single packet buffer so all heads here */
val = VMXNET3_RXD_BTYPE_HEAD;
} else {
/* All BODY type buffers for 2nd ring */
val = VMXNET3_RXD_BTYPE_BODY;
}Quoted 153 lines
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +0
-0devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.numTxQueues = hw->num_tx_queues;lib/librte_pmd_vmxnet3/vmxnet3_ring.h +2
-0@@ -171,6 +171,8 @@ typedef struct vmxnet3_rx_queue {uint32_t qid1;uint32_t qid2;Vmxnet3_RxQueueDesc *shared; +struct rte_mbuf *start_seg; +struct rte_mbuf *last_seg;struct vmxnet3_rxq_stats stats;bool stopped;uint16_t queue_id;/**< Device RX queue index. */
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +45
-30@@ -571,7 +571,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) vmxnet3_rx_queue_t *rxq;Vmxnet3_RxCompDesc *rcd;vmxnet3_buf_info_t *rbi; -Vmxnet3_RxDesc *rxd;struct rte_mbuf *rxm =NULL ;struct vmxnet3_hw *hw;@@ -596,42 +595,18 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) idx = rcd->rxdIdx; ring_idx = (uint8_t )((rcd->rqID == rxq->qid1) ?0 :1 ); - rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; rbi = rxq->cmd_ring[ring_idx].buf_info + idx; -if (unlikely (rcd->sop !=1 || rcd->eop !=1 )) { -rte_pktmbuf_free_seg (rbi->m); -PMD_RX_LOG (DEBUG ,"Packet spread across multiple buffers\n)" ); - goto rcd_done; - }PMD_RX_LOG (DEBUG ,"rxd idx: %d ring idx: %d." , idx, ring_idx);#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +Vmxnet3_RxDesc *rxd + = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;VMXNET3_ASSERT (rcd->len <= rxd->len);VMXNET3_ASSERT (rbi->m);#endif -if (unlikely (rcd->len ==0 )) { -PMD_RX_LOG (DEBUG ,"Rx buf was skipped. rxring[%d][%d]\n)" , - ring_idx, idx); -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -VMXNET3_ASSERT (rcd->sop && rcd->eop); -#endif -rte_pktmbuf_free_seg (rbi->m); - goto rcd_done; - } -/* Assuming a packet is coming in a single packet buffer */ -if (unlikely (rxd->btype !=VMXNET3_RXD_BTYPE_HEAD )) { -PMD_RX_LOG (DEBUG , -"Alert : Misbehaving device, incorrect " -" buffer type used. iPacket dropped." ); -rte_pktmbuf_free_seg (rbi->m); - goto rcd_done; - } -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); -#endif /* Get the packet buffer pointer from buf_info */ rxm = rbi->m;@@ -643,7 +618,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxq->cmd_ring[ring_idx].next2comp = idx;/* For RCD with EOP set, check if there is frame error */ -if (unlikely (rcd->err)) { +if (unlikely (rcd->eop && rcd->err)) { rxq->stats.drop_total++; rxq->stats.drop_err++;@@ -669,9 +644,49 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->ol_flags =0 ; rxm->vlan_tci =0 ; -vmxnet3_rx_offload (rcd, rxm); +/* +* If this is the first buffer of the received packet, +* set the pointer to the first mbuf of the packet +* Otherwise, update the total length and the number of segments +* of the current scattered packet, and update the pointer to +* the last mbuf of the current packet. +*/ +if (rcd->sop) { +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +VMXNET3_ASSERT (!rxq->start_seg); +VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); +#endif + +if (unlikely (rcd->len ==0 )) { +PMD_RX_LOG (DEBUG , +"Rx buf was skipped. rxring[%d][%d])" , + ring_idx, idx); +rte_pktmbuf_free_seg (rbi->m); + goto rcd_done; + } + + rxq->start_seg = rxm; +vmxnet3_rx_offload (rcd, rxm); + }else { +struct rte_mbuf *start = rxq->start_seg; + +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_BODY ); +VMXNET3_ASSERT (start !=NULL ); +#endif + + start->pkt_len += rxm->data_len; + start->nb_segs++; + + rxq->last_seg->next = rxm; + } + rxq->last_seg = rxm; + +if (rcd->eop) { + rx_pkts[nb_rx++] = rxq->start_seg; + rxq->start_seg =NULL ; + } - rx_pkts[nb_rx++] = rxm;
rcd_done:rxq->cmd_ring[ring_idx].next2comp = idx; VMXNET3_INC_RING_IDX_ONLY(rxq->cmd_ring[ring_idx].next2comp,rxq->cmd_ring[ring_idx].size);
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-0@@ -975,6 +990,7 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev) } } rxq->stopped = FALSE; + rxq->start_seg =NULL ; }for (i =0 ; i < dev->data->nb_tx_queues; i++) {Signature · 1 line
2.1.4
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
In reply to a message not in the archiveQuoted 33 lines · Yong Wang
Quoted 30 lines · Stephen Hemminger
From: Stephen Hemminger <[email protected]>
Add support for linking multi-segment buffers together to handle Jumbo packets.
Signed-off-by Stephen Hemminger <[email protected]>---
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c | 3 +- lib/librte_pmd_vmxnet3/vmxnet3_ring.h | 2 + lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c | 76 ++++++++++++++++++++------------- 3 files changed, 50 insertions(+), 31 deletions(-)lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +1
-0@@ -401,6 +401,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) {struct rte_eth_conf port_conf = dev->data->dev_conf;struct vmxnet3_hw *hw = dev->data->dev_private; +uint32_t mtu = dev->data->mtu;Vmxnet3_DriverShared *shared = hw->shared;Vmxnet3_DSDevRead *devRead = &shared->devRead;uint32_t *mac_ptr;@@ -418,7 +419,7 @@ vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) devRead->misc.driverInfo.vmxnet3RevSpt =1 ; devRead->misc.driverInfo.uptVerSpt =1 ;
Quoted 11 lines
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c vmxnet3_setup_driver_shared(struct rte_eth_dev *dev) · line 422
Quoted 2 lines
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +1
-1- devRead->misc.mtu =rte_le_to_cpu_32 (dev->data->mtu); + devRead->misc.mtu =rte_le_to_cpu_32 (mtu);I didn’t see where mtu is used to calculate how many rx descriptors will be needed for each packet. Furthermore, as pointed out by the following code comments, the device requires the first rx buffer of a packet be of type
VMXNET3_RXD_BTYPE_HEADwith the remaining buffers of typeVMXNET3_RXD_BTYPE_NODY. This needs to be taken care of when populating rx rings invmxnet3_post_rx_bufs(). Currently we don’t do this because no scatter-rx is supported and only one descriptor is needed for a packet (thus all types should be HEAD). Otherwise, the device will complain with
To clarify, in this case only the 1st ring will be used and thus all types will be HEAD.
Quoted 182 lines
error returned. For the 2nd rx ring, type needs to be BODY for all descriptors still.
Related to this, could you share what tests have been done to cover these new features?
static int
vmxnet3_post_rx_bufs(vmxnet3_rx_queue_t *rxq, uint8_t ring_id){ int err = 0; uint32_t i = 0, val = 0; struct vmxnet3_cmd_ring *ring = &rxq->cmd_ring[ring_id]; if (ring_id == 0) { /* Usually: One HEAD type buf per packet * val = (ring->next2fill % rxq->hw->bufs_per_pkt) ? * VMXNET3_RXD_BTYPE_BODY : VMXNET3_RXD_BTYPE_HEAD; */ /* We use single packet buffer so all heads here */ val = VMXNET3_RXD_BTYPE_HEAD; } else { /* All BODY type buffers for 2nd ring */ val = VMXNET3_RXD_BTYPE_BODY; }Quoted 153 lines
lib/librte_pmd_vmxnet3/vmxnet3_ethdev.c +0
-0devRead->misc.queueDescPA = hw->queueDescPA; devRead->misc.queueDescLen = hw->queue_desc_len; devRead->misc.numTxQueues = hw->num_tx_queues;lib/librte_pmd_vmxnet3/vmxnet3_ring.h +2
-0@@ -171,6 +171,8 @@ typedef struct vmxnet3_rx_queue {uint32_t qid1;uint32_t qid2;Vmxnet3_RxQueueDesc *shared; +struct rte_mbuf *start_seg; +struct rte_mbuf *last_seg;struct vmxnet3_rxq_stats stats;bool stopped;uint16_t queue_id;/**< Device RX queue index. */
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +45
-30@@ -571,7 +571,6 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) vmxnet3_rx_queue_t *rxq;Vmxnet3_RxCompDesc *rcd;vmxnet3_buf_info_t *rbi; -Vmxnet3_RxDesc *rxd;struct rte_mbuf *rxm =NULL ;struct vmxnet3_hw *hw;@@ -596,42 +595,18 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) idx = rcd->rxdIdx; ring_idx = (uint8_t )((rcd->rqID == rxq->qid1) ?0 :1 ); - rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx; rbi = rxq->cmd_ring[ring_idx].buf_info + idx; -if (unlikely (rcd->sop !=1 || rcd->eop !=1 )) { -rte_pktmbuf_free_seg (rbi->m); -PMD_RX_LOG (DEBUG ,"Packet spread across multiple buffers\n)" ); - goto rcd_done; - }PMD_RX_LOG (DEBUG ,"rxd idx: %d ring idx: %d." , idx, ring_idx);#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +Vmxnet3_RxDesc *rxd + = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;VMXNET3_ASSERT (rcd->len <= rxd->len);VMXNET3_ASSERT (rbi->m);#endif -if (unlikely (rcd->len ==0 )) { -PMD_RX_LOG (DEBUG ,"Rx buf was skipped. rxring[%d][%d]\n)" , - ring_idx, idx); -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -VMXNET3_ASSERT (rcd->sop && rcd->eop); -#endif -rte_pktmbuf_free_seg (rbi->m); - goto rcd_done; - } -/* Assuming a packet is coming in a single packet buffer */ -if (unlikely (rxd->btype !=VMXNET3_RXD_BTYPE_HEAD )) { -PMD_RX_LOG (DEBUG , -"Alert : Misbehaving device, incorrect " -" buffer type used. iPacket dropped." ); -rte_pktmbuf_free_seg (rbi->m); - goto rcd_done; - } -#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER -VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); -#endif /* Get the packet buffer pointer from buf_info */ rxm = rbi->m;@@ -643,7 +618,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxq->cmd_ring[ring_idx].next2comp = idx;/* For RCD with EOP set, check if there is frame error */ -if (unlikely (rcd->err)) { +if (unlikely (rcd->eop && rcd->err)) { rxq->stats.drop_total++; rxq->stats.drop_err++;@@ -669,9 +644,49 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) rxm->ol_flags =0 ; rxm->vlan_tci =0 ; -vmxnet3_rx_offload (rcd, rxm); +/* +* If this is the first buffer of the received packet, +* set the pointer to the first mbuf of the packet +* Otherwise, update the total length and the number of segments +* of the current scattered packet, and update the pointer to +* the last mbuf of the current packet. +*/ +if (rcd->sop) { +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +VMXNET3_ASSERT (!rxq->start_seg); +VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_HEAD ); +#endif + +if (unlikely (rcd->len ==0 )) { +PMD_RX_LOG (DEBUG , +"Rx buf was skipped. rxring[%d][%d])" , + ring_idx, idx); +rte_pktmbuf_free_seg (rbi->m); + goto rcd_done; + } + + rxq->start_seg = rxm; +vmxnet3_rx_offload (rcd, rxm); + }else { +struct rte_mbuf *start = rxq->start_seg; + +#ifdef RTE_LIBRTE_VMXNET3_DEBUG_DRIVER +VMXNET3_ASSERT (rxd->btype ==VMXNET3_RXD_BTYPE_BODY ); +VMXNET3_ASSERT (start !=NULL ); +#endif + + start->pkt_len += rxm->data_len; + start->nb_segs++; + + rxq->last_seg->next = rxm; + } + rxq->last_seg = rxm; + +if (rcd->eop) { + rx_pkts[nb_rx++] = rxq->start_seg; + rxq->start_seg =NULL ; + } - rx_pkts[nb_rx++] = rxm;
rcd_done:rxq->cmd_ring[ring_idx].next2comp = idx; VMXNET3_INC_RING_IDX_ONLY(rxq->cmd_ring[ring_idx].next2comp,rxq->cmd_ring[ring_idx].size);
lib/librte_pmd_vmxnet3/vmxnet3_rxtx.c +1
-0@@ -975,6 +990,7 @@ vmxnet3_dev_rxtx_init(struct rte_eth_dev *dev) } } rxq->stopped = FALSE; + rxq->start_seg =NULL ; }for (i =0 ; i < dev->data->nb_tx_queues; i++) {Signature · 1 line
2.1.4
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
In reply to a message not in the archiveQuoted 10 lines · On Mon, 9 Mar 2015 23:28:39 +0000 Yong Wang…
I didn’t see where mtu is used to calculate how many rx descriptors will be needed for each packet. Furthermore, as pointed out by the following code comments, the device requires the first rx buffer of a packet be of type
VMXNET3_RXD_BTYPE_HEADwith the remaining buffers of typeVMXNET3_RXD_BTYPE_NODY. This needs to be taken care of when populating rx rings invmxnet3_post_rx_bufs(). Currently we don’t do this because no scatter-rx is supported and only one descriptor is needed for a packet (thus all types should be HEAD). Otherwise, the device will complain with error returned. For the 2nd rx ring, type needs to be BODY for all descriptors still.
Yeah the reload logic needs work.
Quoted 2 lines
Related to this, could you share what tests have been done to cover these new features?
Not really. We only test with our product which is built on top of DPDK, not standalone.
Most of these came from figuring what features where missing from the DPDK driver that Intel supplied. I had independently developed a much better virtio and vmxnet3 drivers which were well tested, but DPDK maintainers would not accept wholesale replacement of the driver. Therefore we have been trying to selective add the bits from my driver back into the Intel driver.
2015-03-05 16:10, Stephen Hemminger:
Quoted 6 lines
From: Stephen Hemminger <[email protected]>
Revised version of earlier patches.
Incorporate the small packet optimization
Add more cleanups
Quoted 11 lines
Stephen Hemminger (10):
vmxnet3: fix link state handling
vmxnet3: enable VLAN filtering
vmxnet3: remove mtu check
vmxnet3: cleanup txq stats
vmxnet3: add support for multi-segment transmit
vmxnet3: support RSS and refactor offload
vmxnet3: support jumbo frames
vmxnet3: get rid of DEBUG ifdefs
vmxnet3: add check for jumbo segment
vmxnet3: remove excess inlining
Fixes and cleanup are mostly OK except minor nits. Please fix and re-send them without patches 5 and 7 which are not yet approved (postponed to 2.1).
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
In reply to a message not in the archiveQuoted 10 lines · On Mon, 9 Mar 2015 23:32:48 +0000 Yong Wang…
Quoted 9 lines
I didn’t see where mtu is used to calculate how many rx descriptors will be needed for each packet. Furthermore, as pointed out by the following code comments, the device requires the first rx buffer of a packet be of type
VMXNET3_RXD_BTYPE_HEADwith the remaining buffers of typeVMXNET3_RXD_BTYPE_NODY. This needs to be taken care of when populating rx rings invmxnet3_post_rx_bufs(). Currently we don’t do this because no scatter-rx is supported and only one descriptor is needed for a packet (thus all types should be HEAD). Otherwise, the device will complain with
Quoted 5 lines
To clarify, in this case only the 1st ring will be used and thus all types will be HEAD.
Quoted 2 lines
error returned. For the 2nd rx ring, type needs to be BODY for all descriptors still.
Looking in more detail, the code as submitted looks fine:
* The # of rx descriptors needed for each packet is responsibility of the application. Before and after this patch the # of Rx descriptors for each ring (head/body) is determined by vmxnet3_rx_queue_setup. And the driver always allocates the same number of descriptors for both Rx rings.
One could argue that was a bug in the original driver, since it needlessly allocated mbufs for the second ring and never used them. I suppose as a optimization in future, the second ring could be sized as 0 and no buffers allocated unless doing rx-scatter (this is what the Linux driver does. But that change is independent of this.
* Buffers are correctly reallocated as needed when consumed.
* The code works for bulk transfer and performance tests in jumbo mode.
I see no requirement to change this patch.
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
Quoted 25 lines · Stephen Hemminger
Quoted 10 lines · On Mon, 9 Mar 2015 23:32:48 +0000 Yong Wang <[email protected]> wrote:
Quoted 2 lines
I didn’t see where mtu is used to calculate how many rx descriptors
will
Quoted 1 line
be needed for each packet. Furthermore, as pointed out by the
following
Quoted 1 line
code comments, the device requires the first rx buffer of a packet be
of
Quoted 2 lines
type
VMXNET3_RXD_BTYPE_HEADwith the remaining buffers of typeVMXNET3_RXD_BTYPE_NODY. This needs to be taken care of whenpopulating rx
Quoted 11 lines
Quoted 3 lines
rings in
vmxnet3_post_rx_bufs(). Currently we don’t do this because no scatter-rx is supported and only one descriptor is needed for a packet (thus all types should be HEAD). Otherwise, the device will complainwith
To clarify, in this case only the 1st ring will be used and thus all types
will be HEAD.Quoted 2 lines
error returned. For the 2nd rx ring, type needs to be BODY for all descriptors still.
Quoted 7 lines
Looking in more detail, the code as submitted looks fine:
* The # of rx descriptors needed for each packet is responsibility of the application. Before and after this patch the # of Rx descriptors for each ring (head/body) is determined by
vmxnet3_rx_queue_setup. And the driver always allocates the same number of descriptors for both Rx rings.
Where is vmxnet3_rx_queue_setup? It’s not in the current code base nor in your patch and I failed to see how rx descriptors are populated.
Could you explain what do you mean by responsibility of the application? If mtu is set to 9000, the driver needs to make sure rx buf per packet is set to the correct size with proper type set, right?
Quoted 7 lines
One could argue that was a bug in the original driver, since it
needlessly
allocated mbufs for the second ring and never used them. I suppose as a optimization in future, the second ring could be sized as 0 and no buffers allocated unless doing rx-scatter (this is what the Linux driver does. But that change is independent of this.
We can just keep it as is as we will need it if someone decides to support LRO for vmxnet3.
Quoted 4 lines
* Buffers are correctly reallocated as needed when consumed.
* The code works for bulk transfer and performance tests in jumbo mode.
You mean the standalone patch you posted without the vmxnet3_rx_queue_setup you mentioned?
Quoted 3 lines
I see no requirement to change this patch.
Re: [PATCH v3 07/10] vmxnet3: support jumbo frames
In reply to a message not in the archiveQuoted 8 lines · On Wed, 11 Mar 2015 01:03:37 +0000 Yong Wang…
Quoted 7 lines
Looking in more detail, the code as submitted looks fine:
* The # of rx descriptors needed for each packet is responsibility of the application. Before and after this patch the # of Rx descriptors for each ring (head/body) is determined by
vmxnet3_rx_queue_setup. And the driver always allocates the same number of descriptors for both Rx rings.
Quoted 8 lines
Where is
vmxnet3_rx_queue_setup? It’s not in the current code base nor in your patch and I failed to see how rx descriptors are populated.Could you explain what do you mean by responsibility of the application? If mtu is set to 9000, the driver needs to make sure rx buf per packet is set to the correct size with proper type set, right?
vmxnet3_dev_rx_queue_setup is unchanged from original Intel code.
But you are right there is a bug there since it will error out if max_rx_pkt_len > bufsize. That error check should have been removed. That was an oversight from the merge of our code with the DPDK/Intel code. Just removing the check and surrounding code is all that is necessary.
After that driver will receive scattered mbufs.
None of the DPDK drivers do a good job of checking all the possible misconfiguration of rxmode, jumbo and scattered flags. There is room for improvement in all drivers around that.
Quoted 9 lines
Quoted 6 lines
One could argue that was a bug in the original driver, since it
needlessly
allocated mbufs for the second ring and never used them. I suppose as a optimization in future, the second ring could be sized as 0 and no buffers allocated unless doing rx-scatter (this is what the Linux driver does. But that change is independent of this.We can just keep it as is as we will need it if someone decides to support LRO for vmxnet3.
But LRO must be optional since LRO is broken for the case of forwarding. Linux driver handles the case of only allocating second ring if necessary. Although the Linux vmxnet3 driver was broken about LRO setting for several years, it is fixed now.
Quoted 7 lines
Quoted 4 lines
* Buffers are correctly reallocated as needed when consumed.
* The code works for bulk transfer and performance tests in jumbo mode.
You mean the standalone patch you posted without the
vmxnet3_rx_queue_setupyou mentioned?
The code in recv that calls vmxnet3_post_rx_bufs works for both rings already. It was just until the scattered logic was engaged the second ring was never used.
2015-03-10 14:42, Thomas Monjalon:
Quoted 19 lines
2015-03-05 16:10, Stephen Hemminger:
Quoted 6 lines
From: Stephen Hemminger <[email protected]>
Revised version of earlier patches.
Incorporate the small packet optimization
Add more cleanupsQuoted 11 lines
Stephen Hemminger (10):
vmxnet3: fix link state handling
vmxnet3: enable VLAN filtering
vmxnet3: remove mtu check
vmxnet3: cleanup txq stats
vmxnet3: add support for multi-segment transmit
vmxnet3: support RSS and refactor offload
vmxnet3: support jumbo frames
vmxnet3: get rid of DEBUG ifdefs
vmxnet3: add check for jumbo segment
vmxnet3: remove excess inlining
Quoted 3 lines
Fixes and cleanup are mostly OK except minor nits. Please fix and re-send them without patches 5 and 7 which are not yet approved (postponed to 2.1).
Guys, any news about patches 5 and 7?
Ping Stephen
2015-06-22 14:22, Thomas Monjalon:
Quoted 25 lines
2015-03-10 14:42, Thomas Monjalon:
Quoted 19 lines
2015-03-05 16:10, Stephen Hemminger:
Quoted 6 lines
From: Stephen Hemminger <[email protected]>
Revised version of earlier patches.
Incorporate the small packet optimization
Add more cleanupsQuoted 11 lines
Stephen Hemminger (10):
vmxnet3: fix link state handling
vmxnet3: enable VLAN filtering
vmxnet3: remove mtu check
vmxnet3: cleanup txq stats
vmxnet3: add support for multi-segment transmit
vmxnet3: support RSS and refactor offload
vmxnet3: support jumbo frames
vmxnet3: get rid of DEBUG ifdefs
vmxnet3: add check for jumbo segment
vmxnet3: remove excess inliningQuoted 3 lines
Fixes and cleanup are mostly OK except minor nits. Please fix and re-send them without patches 5 and 7 which are not yet approved (postponed to 2.1).
Guys, any news about patches 5 and 7?