Hi Daiwei: > -----Original Message----- > From: Dai, Wei > Sent: Friday, March 2, 2018 10:11 PM > To: Zhang, Qi Z <qi.z.zh...@intel.com>; Wang, Xiao W > <xiao.w.w...@intel.com> > Cc: dev@dpdk.org; Dai, Wei <wei....@intel.com> > Subject: [PATCH] net/fm10k: convert to new Rx/Tx offloads API > > Ethdev Rx offloads API has changed since: > commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API") Ethdev Tx > offloads API has changed since: > commit cba7f53b717d ("ethdev: introduce Tx queue offloads API") This > commit support the new Rx and Tx offloads API. > > Signed-off-by: Wei Dai <wei....@intel.com> > --- > drivers/net/fm10k/fm10k.h | 7 +++++++ > drivers/net/fm10k/fm10k_ethdev.c | 33 > ++++++++++++++++++++++++--------- > drivers/net/fm10k/fm10k_rxtx_vec.c | 6 +++--- > 3 files changed, 34 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index > 30dad3e..57bd533 100644 > --- a/drivers/net/fm10k/fm10k.h > +++ b/drivers/net/fm10k/fm10k.h > @@ -108,6 +108,11 @@ > > #define FM10K_SIMPLE_TX_FLAG > ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \ > ETH_TXQ_FLAGS_NOOFFLOADS) > +#define FM10K_SIMPLE_TX_OFFLOADS > ((uint64_t)(DEV_TX_OFFLOAD_MULTI_SEGS | \ > + DEV_TX_OFFLOAD_VLAN_INSERT | \ > + DEV_TX_OFFLOAD_SCTP_CKSUM | \ > + DEV_TX_OFFLOAD_UDP_CKSUM | \ > + DEV_TX_OFFLOAD_TCP_CKSUM)) > > struct fm10k_macvlan_filter_info { > uint16_t vlan_num; /* Total VLAN number */ > @@ -180,6 +185,7 @@ struct fm10k_rx_queue { > uint8_t drop_en; > uint8_t rx_deferred_start; /* don't start this queue in dev start. */ > uint16_t rx_ftag_en; /* indicates FTAG RX supported */ > + uint64_t offloads; /* offloads of DEV_RX_OFFLOAD_* */ > }; > > /* > @@ -212,6 +218,7 @@ struct fm10k_tx_queue { > uint16_t next_dd; /* Next pos to check DD flag */ > volatile uint32_t *tail_ptr; > uint32_t txq_flags; /* Holds flags for this TXq */ > + uint64_t offloads; /* Offloads of DEV_TX_OFFLOAD_* */ > uint16_t nb_desc; > uint16_t port_id; > uint8_t tx_deferred_start; /** don't start this queue in dev start. */ > diff > --git a/drivers/net/fm10k/fm10k_ethdev.c > b/drivers/net/fm10k/fm10k_ethdev.c > index 9423761..5105874 100644 > --- a/drivers/net/fm10k/fm10k_ethdev.c > +++ b/drivers/net/fm10k/fm10k_ethdev.c > @@ -444,7 +444,7 @@ fm10k_dev_configure(struct rte_eth_dev *dev) > > PMD_INIT_FUNC_TRACE(); > > - if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) > + if (dev->data->dev_conf.rxmode.offloads & > DEV_RX_OFFLOAD_CRC_STRIP) > PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); > /* multipe queue mode checking */ > ret = fm10k_check_mq_mode(dev); > @@ -454,6 +454,8 @@ fm10k_dev_configure(struct rte_eth_dev *dev) > return ret; > } > > + dev->data->scattered_rx = 0; > + > return 0; > } > > @@ -756,7 +758,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) > /* It adds dual VLAN length for supporting dual VLAN */ > if ((dev->data->dev_conf.rxmode.max_rx_pkt_len + > 2 * FM10K_VLAN_TAG_SIZE) > buf_size || > - dev->data->dev_conf.rxmode.enable_scatter) { > + rxq->offloads & DEV_RX_OFFLOAD_SCATTER) { > uint32_t reg; > dev->data->scattered_rx = 1; > reg = FM10K_READ_REG(hw, FM10K_SRRCTL(i)); @@ > -1389,11 +1391,17 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, > dev_info->vmdq_queue_base = 0; > dev_info->max_vmdq_pools = ETH_32_POOLS; > dev_info->vmdq_queue_num = FM10K_MAX_QUEUES_PF; > + dev_info->rx_queue_offload_capa = DEV_RX_OFFLOAD_SCATTER; > dev_info->rx_offload_capa = > - DEV_RX_OFFLOAD_VLAN_STRIP | > - DEV_RX_OFFLOAD_IPV4_CKSUM | > - DEV_RX_OFFLOAD_UDP_CKSUM | > - DEV_RX_OFFLOAD_TCP_CKSUM; > + DEV_RX_OFFLOAD_VLAN_STRIP | > + DEV_RX_OFFLOAD_VLAN_FILTER | > + DEV_RX_OFFLOAD_IPV4_CKSUM | > + DEV_RX_OFFLOAD_UDP_CKSUM | > + DEV_RX_OFFLOAD_TCP_CKSUM | > + DEV_RX_OFFLOAD_JUMBO_FRAME | > + DEV_RX_OFFLOAD_CRC_STRIP | > + DEV_RX_OFFLOAD_SCATTER; > + dev_info->tx_queue_offload_capa = 0; > dev_info->tx_offload_capa = > DEV_TX_OFFLOAD_VLAN_INSERT | > DEV_TX_OFFLOAD_IPV4_CKSUM | > @@ -1412,6 +1420,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, > }, > .rx_free_thresh = FM10K_RX_FREE_THRESH_DEFAULT(0), > .rx_drop_en = 0, > + .offloads = 0, > }; > > dev_info->default_txconf = (struct rte_eth_txconf) { @@ -1423,6 > +1432,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, > .tx_free_thresh = FM10K_TX_FREE_THRESH_DEFAULT(0), > .tx_rs_thresh = FM10K_TX_RS_THRESH_DEFAULT(0), > .txq_flags = FM10K_SIMPLE_TX_FLAG, > + .offloads = 0, > }; > > dev_info->rx_desc_lim = (struct rte_eth_desc_lim) { @@ -1571,19 > +1581,22 @@ static int fm10k_vlan_offload_set(struct rte_eth_dev *dev, > int mask) { > if (mask & ETH_VLAN_STRIP_MASK) { > - if (!dev->data->dev_conf.rxmode.hw_vlan_strip) > + if (!(dev->data->dev_conf.rxmode.offloads & > + DEV_RX_OFFLOAD_VLAN_STRIP)) > PMD_INIT_LOG(ERR, "VLAN stripping is " > "always on in fm10k"); > } > > if (mask & ETH_VLAN_EXTEND_MASK) { > - if (dev->data->dev_conf.rxmode.hw_vlan_extend) > + if (dev->data->dev_conf.rxmode.offloads & > + DEV_RX_OFFLOAD_VLAN_EXTEND)
Seems DEV_RX_OFFLOAD_VLAN_EXTEND is missed in fm10k_dev_infos_get? > PMD_INIT_LOG(ERR, "VLAN QinQ is not " > "supported in fm10k"); > } > > if (mask & ETH_VLAN_FILTER_MASK) { > - if (!dev->data->dev_conf.rxmode.hw_vlan_filter) > + if (!(dev->data->dev_conf.rxmode.offloads & > + DEV_RX_OFFLOAD_VLAN_FILTER)) > PMD_INIT_LOG(ERR, "VLAN filter is always on in fm10k"); > } > > @@ -1879,6 +1892,7 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, > uint16_t queue_id, > fm10k_rxq_vec_setup(q); > > dev->data->rx_queues[queue_id] = q; > + q->offloads = conf->offloads; > return 0; > } > > @@ -1995,6 +2009,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, > uint16_t queue_id, > q->port_id = dev->data->port_id; > q->queue_id = queue_id; > q->txq_flags = conf->txq_flags; > + q->offloads = conf->offloads; > q->ops = &def_txq_ops; > q->tail_ptr = (volatile uint32_t *) > &((uint32_t *)hw->hw_addr)[FM10K_TDT(queue_id)]; > diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c > b/drivers/net/fm10k/fm10k_rxtx_vec.c > index 498a178..e6dba04 100644 > --- a/drivers/net/fm10k/fm10k_rxtx_vec.c > +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c > @@ -210,7 +210,7 @@ fm10k_rx_vec_condition_check(struct rte_eth_dev > *dev) > > #ifndef RTE_FM10K_RX_OLFLAGS_ENABLE > /* whithout rx ol_flags, no VP flag report */ > - if (rxmode->hw_vlan_extend != 0) > + if (rxmode->offloads & DEV_RX_OFFLOAD_VLAN_EXTEND) > return -1; > #endif > > @@ -219,7 +219,7 @@ fm10k_rx_vec_condition_check(struct rte_eth_dev > *dev) > return -1; > > /* no header split support */ > - if (rxmode->header_split == 1) > + if (rxmode->offloads & DEV_RX_OFFLOAD_HEADER_SPLIT) DEV_RX_OFFLOAD_HEADER_SPLIT also missed in fm10k_dev_infos_get? > return -1; > > return 0; > @@ -695,7 +695,7 @@ int __attribute__((cold)) > fm10k_tx_vec_condition_check(struct fm10k_tx_queue *txq) { > /* Vector TX can't offload any features yet */ > - if ((txq->txq_flags & FM10K_SIMPLE_TX_FLAG) != > FM10K_SIMPLE_TX_FLAG) > + if (txq->offloads & FM10K_SIMPLE_TX_OFFLOADS) > return -1; Is this correct? an offload not include in FM10K_SIMPLE_TX_OFFLOADS will also fail this branch and pass check, right? The logic can be implemented like below: #define FM10K_VEC_TX_OFFLOAD_SUPPORT xxx | xxx ... If (txq->offloads & FM10K_VEC_TX_OFFLOAD_SUPPORT != txq->offload) return -1 Regards Qi > > if (txq->tx_ftag_en) > -- > 2.9.4