* [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support @ 2015-09-30 7:28 Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking Shaopeng He ` (3 more replies) 0 siblings, 4 replies; 27+ messages in thread From: Shaopeng He @ 2015-09-30 7:28 UTC (permalink / raw) To: dev This patch series adds VMDQ support to fm10k. It includes the functions to configure VMDQ mode and add MAC address for each VMDQ queue pool. It also includes logic to do sanity check for multi-queue settings. 1. implement rx_descriptor_done function in fm10k 2. make sure default VID available in dev_init in fm10k 3. fix a memory leak for non-ip packet in l3fwd-power 4. add rx interrupt support in fm10k PF and VF Shaopeng He (3): fm10k: add multi-queue checking fm10k: add VMDQ support in MAC/VLAN filter fm10k: add VMDQ support in multi-queue configure drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 358 ++++++++++++++++++++++++++++++--------- 2 files changed, 284 insertions(+), 77 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking 2015-09-30 7:28 [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support Shaopeng He @ 2015-09-30 7:28 ` Shaopeng He 2015-10-15 6:27 ` Qiu, Michael 2015-09-30 7:28 ` [dpdk-dev] [PATCH 2/3] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He ` (2 subsequent siblings) 3 siblings, 1 reply; 27+ messages in thread From: Shaopeng He @ 2015-09-30 7:28 UTC (permalink / raw) To: dev Add multi-queue checking in device configure process. Currently, VMDQ and RSS are supported. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index a69c990..082937d 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) } static int +fm10k_check_mq_mode(struct rte_eth_dev *dev) +{ + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint16_t nb_rx_q = dev->data->nb_rx_queues; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { + PMD_INIT_LOG(ERR, "DCB mode is not supported."); + return -EINVAL; + } + + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) + return 0; + + if (hw->mac.type == fm10k_mac_vf) { + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); + return -EINVAL; + } + + /* Check VMDQ queue pool number */ + if (vmdq_conf->nb_queue_pools > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT || + vmdq_conf->nb_queue_pools > nb_rx_q) { + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", + vmdq_conf->nb_queue_pools); + return -EINVAL; + } + + return 0; +} + +static int fm10k_dev_configure(struct rte_eth_dev *dev) { + int ret; + PMD_INIT_FUNC_TRACE(); if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); + /* multipe queue mode checking */ + ret = fm10k_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", + ret); + return ret; + } return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking 2015-09-30 7:28 ` [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking Shaopeng He @ 2015-10-15 6:27 ` Qiu, Michael 2015-10-15 11:07 ` He, Shaopeng 0 siblings, 1 reply; 27+ messages in thread From: Qiu, Michael @ 2015-10-15 6:27 UTC (permalink / raw) To: He, Shaopeng, dev On 2015/9/30 15:29, Shaopeng He wrote: > Add multi-queue checking in device configure process. > Currently, VMDQ and RSS are supported. > > Signed-off-by: Shaopeng He <shaopeng.he@intel.com> > --- > drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 44 insertions(+) > > diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c > index a69c990..082937d 100644 > --- a/drivers/net/fm10k/fm10k_ethdev.c > +++ b/drivers/net/fm10k/fm10k_ethdev.c > @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) > } > > static int > +fm10k_check_mq_mode(struct rte_eth_dev *dev) > +{ > + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; > + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); > + struct rte_eth_vmdq_rx_conf *vmdq_conf; > + uint16_t nb_rx_q = dev->data->nb_rx_queues; > + > + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; > + > + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { > + PMD_INIT_LOG(ERR, "DCB mode is not supported."); > + return -EINVAL; > + } > + > + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) > + return 0; > + > + if (hw->mac.type == fm10k_mac_vf) { > + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); > + return -EINVAL; > + } I think vf check should be the first one, then we do not need check dcb and VMDq flag. Thanks, Michael > + > + /* Check VMDQ queue pool number */ > + if (vmdq_conf->nb_queue_pools > > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT || > + vmdq_conf->nb_queue_pools > nb_rx_q) { > + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", > + vmdq_conf->nb_queue_pools); > + return -EINVAL; > + } > + > + return 0; > +} > + > +static int > fm10k_dev_configure(struct rte_eth_dev *dev) > { > + int ret; > + > PMD_INIT_FUNC_TRACE(); > > if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) > PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); > + /* multipe queue mode checking */ > + ret = fm10k_check_mq_mode(dev); > + if (ret != 0) { > + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", > + ret); > + return ret; > + } > > return 0; > } ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking 2015-10-15 6:27 ` Qiu, Michael @ 2015-10-15 11:07 ` He, Shaopeng 2015-10-22 1:23 ` Qiu, Michael 0 siblings, 1 reply; 27+ messages in thread From: He, Shaopeng @ 2015-10-15 11:07 UTC (permalink / raw) To: Qiu, Michael, dev Hi, Michael > -----Original Message----- > From: Qiu, Michael > Sent: Thursday, October 15, 2015 2:28 PM > To: He, Shaopeng; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking > > On 2015/9/30 15:29, Shaopeng He wrote: > > Add multi-queue checking in device configure process. > > Currently, VMDQ and RSS are supported. > > > > Signed-off-by: Shaopeng He <shaopeng.he@intel.com> > > --- > > drivers/net/fm10k/fm10k_ethdev.c | 44 > > ++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 44 insertions(+) > > > > diff --git a/drivers/net/fm10k/fm10k_ethdev.c > > b/drivers/net/fm10k/fm10k_ethdev.c > > index a69c990..082937d 100644 > > --- a/drivers/net/fm10k/fm10k_ethdev.c > > +++ b/drivers/net/fm10k/fm10k_ethdev.c > > @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, > uint16_t > > qnum) } > > > > static int > > +fm10k_check_mq_mode(struct rte_eth_dev *dev) { > > + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data- > >dev_conf.rxmode.mq_mode; > > + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data- > >dev_private); > > + struct rte_eth_vmdq_rx_conf *vmdq_conf; > > + uint16_t nb_rx_q = dev->data->nb_rx_queues; > > + > > + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; > > + > > + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { > > + PMD_INIT_LOG(ERR, "DCB mode is not supported."); > > + return -EINVAL; > > + } > > + > > + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) > > + return 0; > > + > > + if (hw->mac.type == fm10k_mac_vf) { > > + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); > > + return -EINVAL; > > + } > > I think vf check should be the first one, then we do not need check dcb and > VMDq flag. > > Thanks, > Michael Thanks for the comments. There is a case of RSS support on VF, if vf check be the first one, it will return fail, which is not correct. Thanks, --Shaopeng > > + > > + /* Check VMDQ queue pool number */ > > + if (vmdq_conf->nb_queue_pools > > > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT > || > > + vmdq_conf->nb_queue_pools > nb_rx_q) { > > + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", > > + vmdq_conf->nb_queue_pools); > > + return -EINVAL; > > + } > > + > > + return 0; > > +} > > + > > +static int > > fm10k_dev_configure(struct rte_eth_dev *dev) { > > + int ret; > > + > > PMD_INIT_FUNC_TRACE(); > > > > if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) > > PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); > > + /* multipe queue mode checking */ > > + ret = fm10k_check_mq_mode(dev); > > + if (ret != 0) { > > + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails > with %d.", > > + ret); > > + return ret; > > + } > > > > return 0; > > } ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking 2015-10-15 11:07 ` He, Shaopeng @ 2015-10-22 1:23 ` Qiu, Michael 0 siblings, 0 replies; 27+ messages in thread From: Qiu, Michael @ 2015-10-22 1:23 UTC (permalink / raw) To: He, Shaopeng, dev On 2015/10/15 19:07, He, Shaopeng wrote: > Hi, Michael > >> -----Original Message----- >> From: Qiu, Michael >> Sent: Thursday, October 15, 2015 2:28 PM >> To: He, Shaopeng; dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking >> >> On 2015/9/30 15:29, Shaopeng He wrote: >>> Add multi-queue checking in device configure process. >>> Currently, VMDQ and RSS are supported. >>> >>> Signed-off-by: Shaopeng He <shaopeng.he@intel.com> >>> --- >>> drivers/net/fm10k/fm10k_ethdev.c | 44 >>> ++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 44 insertions(+) >>> >>> diff --git a/drivers/net/fm10k/fm10k_ethdev.c >>> b/drivers/net/fm10k/fm10k_ethdev.c >>> index a69c990..082937d 100644 >>> --- a/drivers/net/fm10k/fm10k_ethdev.c >>> +++ b/drivers/net/fm10k/fm10k_ethdev.c >>> @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, >> uint16_t >>> qnum) } >>> >>> static int >>> +fm10k_check_mq_mode(struct rte_eth_dev *dev) { >>> + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data- >>> dev_conf.rxmode.mq_mode; >>> + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data- >>> dev_private); >>> + struct rte_eth_vmdq_rx_conf *vmdq_conf; >>> + uint16_t nb_rx_q = dev->data->nb_rx_queues; >>> + >>> + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; >>> + >>> + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { >>> + PMD_INIT_LOG(ERR, "DCB mode is not supported."); >>> + return -EINVAL; >>> + } >>> + >>> + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) >>> + return 0; >>> + >>> + if (hw->mac.type == fm10k_mac_vf) { >>> + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); >>> + return -EINVAL; >>> + } >> I think vf check should be the first one, then we do not need check dcb and >> VMDq flag. >> >> Thanks, >> Michael > Thanks for the comments. There is a case of RSS support on VF, if vf check be > the first one, it will return fail, which is not correct. OK, you are right. Thanks, Michael > Thanks, > --Shaopeng >>> + >>> + /* Check VMDQ queue pool number */ >>> + if (vmdq_conf->nb_queue_pools > >>> + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT >> || >>> + vmdq_conf->nb_queue_pools > nb_rx_q) { >>> + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", >>> + vmdq_conf->nb_queue_pools); >>> + return -EINVAL; >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +static int >>> fm10k_dev_configure(struct rte_eth_dev *dev) { >>> + int ret; >>> + >>> PMD_INIT_FUNC_TRACE(); >>> >>> if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) >>> PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); >>> + /* multipe queue mode checking */ >>> + ret = fm10k_check_mq_mode(dev); >>> + if (ret != 0) { >>> + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails >> with %d.", >>> + ret); >>> + return ret; >>> + } >>> >>> return 0; >>> } > ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 2/3] fm10k: add VMDQ support in MAC/VLAN filter 2015-09-30 7:28 [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking Shaopeng He @ 2015-09-30 7:28 ` Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 3/3] fm10k: add VMDQ support in multi-queue configure Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He 3 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-09-30 7:28 UTC (permalink / raw) To: dev The patch does below things for fm10k MAC/VLAN filter: - Add separate functions to add MAC address for VMDQ and main VSI. - Disable modification to VLAN filter in VMDQ mode. - In device close phase, delete logic ports to remove all the MAC/VLAN filters. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++-------------- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index c089882..439e95f 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -126,6 +126,9 @@ struct fm10k_macvlan_filter_info { uint16_t vlan_num; /* Total VLAN number */ uint16_t mac_num; /* Total mac number */ + uint16_t nb_queue_pools; /* Active queue pools number */ + /* VMDQ ID for each MAC address */ + uint8_t mac_vmdq_id[FM10K_MAX_MACADDR_NUM]; uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */ }; diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 082937d..cf48cd5 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -45,6 +45,8 @@ #define FM10K_MBXLOCK_DELAY_US 20 #define UINT64_LOWER_32BITS_MASK 0x00000000ffffffffULL +#define MAIN_VSI_POOL_NUMBER 0 + /* Max try times to acquire switch status */ #define MAX_QUERY_SWITCH_STATE_TIMES 10 /* Wait interval to get switch status */ @@ -61,10 +63,8 @@ static void fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev); static inline int fm10k_glort_valid(struct fm10k_hw *hw); static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add); -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev); +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool); static void fm10k_tx_queue_release(void *queue); static void fm10k_rx_queue_release(void *queue); @@ -883,10 +883,17 @@ static void fm10k_dev_close(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint16_t nb_lport; + struct fm10k_macvlan_filter_info *macvlan; PMD_INIT_FUNC_TRACE(); - fm10k_MACVLAN_remove_all(dev); + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_lport = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + fm10k_mbx_lock(hw); + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport, false); + fm10k_mbx_unlock(hw); /* Stop mailbox service first */ fm10k_close_mbx_service(hw); @@ -1023,6 +1030,11 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + if (macvlan->nb_queue_pools > 0) { /* VMDQ mode */ + PMD_INIT_LOG(ERR, "Cannot change VLAN filter in VMDQ mode"); + return (-EINVAL); + } + if (vlan_id > ETH_VLAN_ID_MAX) { PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096"); return (-EINVAL); @@ -1100,38 +1112,80 @@ fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) } } -/* Add/Remove a MAC address, and update filters */ -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) +/* Add/Remove a MAC address, and update filters to main VSI */ +static void fm10k_MAC_filter_set_main_vsi(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) { - uint32_t i, j, k; - struct fm10k_hw *hw; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct fm10k_macvlan_filter_info *macvlan; + uint32_t i, j, k; - hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - i = 0; - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) { - if (i + 1 > macvlan->vlan_num) { - PMD_INIT_LOG(ERR, "vlan number " - "not match"); - return; - } - fm10k_mbx_lock(hw); - fm10k_update_uc_addr(hw, - hw->mac.dglort_map, mac, - j * FM10K_UINT32_BIT_SIZE + k, - add, 0); - fm10k_mbx_unlock(hw); - i++; - } + if (pool != MAIN_VSI_POOL_NUMBER) { + PMD_DRV_LOG(ERR, "VMDQ not enabled, can't set " + "mac to pool %u", pool); + return; + } + for (i = 0, j = 0; j < FM10K_VFTA_SIZE; j++) { + if (!macvlan->vfta[j]) + continue; + for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { + if (!(macvlan->vfta[j] & (1 << k))) + continue; + if (i + 1 > macvlan->vlan_num) { + PMD_INIT_LOG(ERR, "vlan number not match"); + return; } + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map, mac, + j * FM10K_UINT32_BIT_SIZE + k, add, 0); + fm10k_mbx_unlock(hw); + i++; } } +} + +/* Add/Remove a MAC address, and update filters to VMDQ */ +static void fm10k_MAC_filter_set_vmdq(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct fm10k_macvlan_filter_info *macvlan; + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (pool > macvlan->nb_queue_pools) { + PMD_DRV_LOG(ERR, "Pool number %u invalid." + " Max pool is %u", + pool, macvlan->nb_queue_pools); + return; + } + for (i = 0; i < (int)vmdq_conf->nb_pool_maps; i++) { + if (!(vmdq_conf->pool_map[i].pools & (1UL << pool))) + continue; + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map + pool, mac, + vmdq_conf->pool_map[i].vlan_id, add, 0); + fm10k_mbx_unlock(hw); + } +} + +/* Add/Remove a MAC address, and update filters */ +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + + if (macvlan->nb_queue_pools > 0) /* VMDQ mode */ + fm10k_MAC_filter_set_vmdq(dev, mac, add, pool); + else + fm10k_MAC_filter_set_main_vsi(dev, mac, add, pool); if (add) macvlan->mac_num++; @@ -1142,11 +1196,15 @@ fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) /* Add a MAC address, and update filters */ static void fm10k_macaddr_add(struct rte_eth_dev *dev, - struct ether_addr *mac_addr, - __rte_unused uint32_t index, - __rte_unused uint32_t pool) + struct ether_addr *mac_addr, + uint32_t index, + uint32_t pool) { - fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE); + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE, pool); + macvlan->mac_vmdq_id[index] = pool; } /* Remove a MAC address, and update filters */ @@ -1154,29 +1212,12 @@ static void fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) { struct rte_eth_dev_data *data = dev->data; - - if (index < FM10K_MAX_MACADDR_NUM) - fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, - FALSE); -} - -/* Remove all VLAN and MAC address table entries */ -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev) -{ - uint32_t j, k; struct fm10k_macvlan_filter_info *macvlan; macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) - fm10k_vlan_filter_set(dev, - j * FM10K_UINT32_BIT_SIZE + k, false); - } - } - } + fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, + FALSE, macvlan->mac_vmdq_id[index]); + macvlan->mac_vmdq_id[index] = 0; } static inline int @@ -2266,7 +2307,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) fm10k_mbx_unlock(hw); /* Add default mac address */ - fm10k_MAC_filter_set(dev, hw->mac.addr, true); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 3/3] fm10k: add VMDQ support in multi-queue configure 2015-09-30 7:28 [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 2/3] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He @ 2015-09-30 7:28 ` Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He 3 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-09-30 7:28 UTC (permalink / raw) To: dev Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ configure was changed. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 23 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index cf48cd5..4d6dd57 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -337,8 +337,43 @@ fm10k_dev_configure(struct rte_eth_dev *dev) return 0; } +/* fls = find last set bit = 32 minus the number of leading zeros */ +#ifndef fls +#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) +#endif + static void -fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +fm10k_dev_vmdq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + for (i = 0; i < vmdq_conf->nb_pool_maps; i++) { + if (!vmdq_conf->pool_map[i].pools) + continue; + fm10k_mbx_lock(hw); + fm10k_update_vlan(hw, vmdq_conf->pool_map[i].vlan_id, 0, true); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_pf_main_vsi_reset(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* Add default mac address */ + ether_addr_copy((const struct ether_addr *)hw->mac.addr, + &dev->data->mac_addrs[0]); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); +} + +static void +fm10k_dev_rss_configure(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_conf *dev_conf = &dev->data->dev_conf; @@ -409,6 +444,76 @@ fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) FM10K_WRITE_REG(hw, FM10K_MRQC(0), mrqc); } +static void +fm10k_dev_logic_port_update(struct rte_eth_dev *dev, + uint16_t nb_lport_old, uint16_t nb_lport_new) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t i; + + fm10k_mbx_lock(hw); + /* Disable previous logic ports */ + if (nb_lport_old) + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_old, false); + /* Enable new logic ports */ + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_new, true); + fm10k_mbx_unlock(hw); + + for (i = 0; i < nb_lport_new; i++) { + /* Set unicast mode by default. App can change + * to other mode in other API func. + */ + fm10k_mbx_lock(hw); + hw->mac.ops.update_xcast_mode(hw, hw->mac.dglort_map + i, + FM10K_XCAST_MODE_NONE); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + struct rte_eth_conf *dev_conf = &dev->data->dev_conf; + struct fm10k_macvlan_filter_info *macvlan; + uint16_t nb_queue_pools = 0; /* pool number in configuration */ + uint16_t nb_lport_new, nb_lport_old; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + fm10k_dev_rss_configure(dev); + + /* only PF supports VMDQ */ + if (hw->mac.type != fm10k_mac_pf) + return; + + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) + nb_queue_pools = vmdq_conf->nb_queue_pools; + + /* no pool number change, no need to update logic port and VLAN/MAC */ + if (macvlan->nb_queue_pools == nb_queue_pools) + return; + + nb_lport_old = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + nb_lport_new = nb_queue_pools ? nb_queue_pools : 1; + fm10k_dev_logic_port_update(dev, nb_lport_old, nb_lport_new); + + /* reset MAC/VLAN as it's based on VMDQ or PF default VSI */ + memset(dev->data->mac_addrs, 0, + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM); + memset(macvlan, 0, sizeof(*macvlan)); + macvlan->nb_queue_pools = nb_queue_pools; + + if (nb_queue_pools) + fm10k_dev_vmdq_rx_configure(dev); + else + fm10k_dev_pf_main_vsi_reset(dev); +} + static int fm10k_dev_tx_init(struct rte_eth_dev *dev) { @@ -517,7 +622,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) FM10K_WRITE_FLUSH(hw); } - /* Configure RSS if applicable */ + /* Configure VMDQ/RSS if applicable */ fm10k_dev_mq_rx_configure(dev); return 0; } @@ -747,10 +852,32 @@ fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast mode"); } -/* fls = find last set bit = 32 minus the number of leading zeros */ -#ifndef fls -#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) -#endif +static void +fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t dglortdec, pool_len, rss_len, i; + uint16_t nb_queue_pools; + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_queue_pools = macvlan->nb_queue_pools; + pool_len = nb_queue_pools ? fls(nb_queue_pools - 1) : 0; + rss_len = fls(dev->data->nb_rx_queues - 1) - pool_len; + dglortdec = (rss_len << FM10K_DGLORTDEC_RSSLENGTH_SHIFT) | pool_len; + + /* Establish only MAP 0 as valid */ + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); + + /* Configure VMDQ/RSS DGlort Decoder */ + FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), dglortdec); + + /* Invalidate all other GLORT entries */ + for (i = 1; i < FM10K_DGLORT_COUNT; i++) + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), + FM10K_DGLORTMAP_NONE); +} + #define BSIZEPKT_ROUNDUP ((1 << FM10K_SRRCTL_BSIZEPKT_SHIFT) - 1) static int fm10k_dev_start(struct rte_eth_dev *dev) @@ -791,20 +918,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) return diag; } - if (hw->mac.type == fm10k_mac_pf) { - /* Establish only VSI 0 as valid */ - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); - - /* Configure RSS bits used in RETA table */ - FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), - fls(dev->data->nb_rx_queues - 1) << - FM10K_DGLORTDEC_RSSLENGTH_SHIFT); - - /* Invalidate all other GLORT entries */ - for (i = 1; i < FM10K_DGLORT_COUNT; i++) - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), - FM10K_DGLORTMAP_NONE); - } + if (hw->mac.type == fm10k_mac_pf) + fm10k_dev_dglort_map_configure(dev); for (i = 0; i < dev->data->nb_rx_queues; i++) { struct fm10k_rx_queue *rxq; @@ -838,8 +953,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) } } - /* Update default vlan */ - if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) + /* Update default vlan when not in VMDQ mode */ + if (!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG)) fm10k_vlan_filter_set(dev, hw->mac.default_vid, true); return 0; @@ -978,7 +1093,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM; dev_info->max_hash_mac_addrs = 0; dev_info->max_vfs = dev->pci_dev->max_vfs; - dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->vmdq_pool_base = 0; + 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_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | DEV_RX_OFFLOAD_IPV4_CKSUM | -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support 2015-09-30 7:28 [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support Shaopeng He ` (2 preceding siblings ...) 2015-09-30 7:28 ` [dpdk-dev] [PATCH 3/3] fm10k: add VMDQ support in multi-queue configure Shaopeng He @ 2015-10-10 3:22 ` Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 1/4] fm10k: add multi-queue checking Shaopeng He ` (4 more replies) 3 siblings, 5 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-10 3:22 UTC (permalink / raw) To: dev This patch series adds VMDQ support for fm10k. It includes the functions to configure VMDQ mode and add MAC address for each VMDQ queue pool. It also includes logic to do sanity check for multi-queue settings. Changes in v2: - Reword some comments and commit messages - Updated release note Shaopeng He (4): fm10k: add multi-queue checking fm10k: add VMDQ support in MAC/VLAN filter fm10k: add VMDQ support in multi-queue configure doc: update release note for fm10k VMDQ support doc/guides/rel_notes/release_2_2.rst | 5 + drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 358 +++++++++++++++++++++++++++-------- 3 files changed, 289 insertions(+), 77 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 1/4] fm10k: add multi-queue checking 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He @ 2015-10-10 3:22 ` Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He ` (3 subsequent siblings) 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-10 3:22 UTC (permalink / raw) To: dev Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index a69c990..082937d 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) } static int +fm10k_check_mq_mode(struct rte_eth_dev *dev) +{ + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint16_t nb_rx_q = dev->data->nb_rx_queues; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { + PMD_INIT_LOG(ERR, "DCB mode is not supported."); + return -EINVAL; + } + + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) + return 0; + + if (hw->mac.type == fm10k_mac_vf) { + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); + return -EINVAL; + } + + /* Check VMDQ queue pool number */ + if (vmdq_conf->nb_queue_pools > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT || + vmdq_conf->nb_queue_pools > nb_rx_q) { + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", + vmdq_conf->nb_queue_pools); + return -EINVAL; + } + + return 0; +} + +static int fm10k_dev_configure(struct rte_eth_dev *dev) { + int ret; + PMD_INIT_FUNC_TRACE(); if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); + /* multipe queue mode checking */ + ret = fm10k_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", + ret); + return ret; + } return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 2/4] fm10k: add VMDQ support in MAC/VLAN filter 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 1/4] fm10k: add multi-queue checking Shaopeng He @ 2015-10-10 3:22 ` Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He ` (2 subsequent siblings) 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-10 3:22 UTC (permalink / raw) To: dev The patch does below things for fm10k MAC/VLAN filter: - Add separate functions for VMDQ and main VSI to change MAC filter. - Disable modification to VLAN filter in VMDQ mode. - In device close phase, delete logic ports to remove all MAC/VLAN filters belonging to those ports. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++-------------- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index c089882..439e95f 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -126,6 +126,9 @@ struct fm10k_macvlan_filter_info { uint16_t vlan_num; /* Total VLAN number */ uint16_t mac_num; /* Total mac number */ + uint16_t nb_queue_pools; /* Active queue pools number */ + /* VMDQ ID for each MAC address */ + uint8_t mac_vmdq_id[FM10K_MAX_MACADDR_NUM]; uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */ }; diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 082937d..cf48cd5 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -45,6 +45,8 @@ #define FM10K_MBXLOCK_DELAY_US 20 #define UINT64_LOWER_32BITS_MASK 0x00000000ffffffffULL +#define MAIN_VSI_POOL_NUMBER 0 + /* Max try times to acquire switch status */ #define MAX_QUERY_SWITCH_STATE_TIMES 10 /* Wait interval to get switch status */ @@ -61,10 +63,8 @@ static void fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev); static inline int fm10k_glort_valid(struct fm10k_hw *hw); static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add); -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev); +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool); static void fm10k_tx_queue_release(void *queue); static void fm10k_rx_queue_release(void *queue); @@ -883,10 +883,17 @@ static void fm10k_dev_close(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint16_t nb_lport; + struct fm10k_macvlan_filter_info *macvlan; PMD_INIT_FUNC_TRACE(); - fm10k_MACVLAN_remove_all(dev); + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_lport = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + fm10k_mbx_lock(hw); + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport, false); + fm10k_mbx_unlock(hw); /* Stop mailbox service first */ fm10k_close_mbx_service(hw); @@ -1023,6 +1030,11 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + if (macvlan->nb_queue_pools > 0) { /* VMDQ mode */ + PMD_INIT_LOG(ERR, "Cannot change VLAN filter in VMDQ mode"); + return (-EINVAL); + } + if (vlan_id > ETH_VLAN_ID_MAX) { PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096"); return (-EINVAL); @@ -1100,38 +1112,80 @@ fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) } } -/* Add/Remove a MAC address, and update filters */ -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) +/* Add/Remove a MAC address, and update filters to main VSI */ +static void fm10k_MAC_filter_set_main_vsi(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) { - uint32_t i, j, k; - struct fm10k_hw *hw; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct fm10k_macvlan_filter_info *macvlan; + uint32_t i, j, k; - hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - i = 0; - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) { - if (i + 1 > macvlan->vlan_num) { - PMD_INIT_LOG(ERR, "vlan number " - "not match"); - return; - } - fm10k_mbx_lock(hw); - fm10k_update_uc_addr(hw, - hw->mac.dglort_map, mac, - j * FM10K_UINT32_BIT_SIZE + k, - add, 0); - fm10k_mbx_unlock(hw); - i++; - } + if (pool != MAIN_VSI_POOL_NUMBER) { + PMD_DRV_LOG(ERR, "VMDQ not enabled, can't set " + "mac to pool %u", pool); + return; + } + for (i = 0, j = 0; j < FM10K_VFTA_SIZE; j++) { + if (!macvlan->vfta[j]) + continue; + for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { + if (!(macvlan->vfta[j] & (1 << k))) + continue; + if (i + 1 > macvlan->vlan_num) { + PMD_INIT_LOG(ERR, "vlan number not match"); + return; } + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map, mac, + j * FM10K_UINT32_BIT_SIZE + k, add, 0); + fm10k_mbx_unlock(hw); + i++; } } +} + +/* Add/Remove a MAC address, and update filters to VMDQ */ +static void fm10k_MAC_filter_set_vmdq(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct fm10k_macvlan_filter_info *macvlan; + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (pool > macvlan->nb_queue_pools) { + PMD_DRV_LOG(ERR, "Pool number %u invalid." + " Max pool is %u", + pool, macvlan->nb_queue_pools); + return; + } + for (i = 0; i < (int)vmdq_conf->nb_pool_maps; i++) { + if (!(vmdq_conf->pool_map[i].pools & (1UL << pool))) + continue; + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map + pool, mac, + vmdq_conf->pool_map[i].vlan_id, add, 0); + fm10k_mbx_unlock(hw); + } +} + +/* Add/Remove a MAC address, and update filters */ +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + + if (macvlan->nb_queue_pools > 0) /* VMDQ mode */ + fm10k_MAC_filter_set_vmdq(dev, mac, add, pool); + else + fm10k_MAC_filter_set_main_vsi(dev, mac, add, pool); if (add) macvlan->mac_num++; @@ -1142,11 +1196,15 @@ fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) /* Add a MAC address, and update filters */ static void fm10k_macaddr_add(struct rte_eth_dev *dev, - struct ether_addr *mac_addr, - __rte_unused uint32_t index, - __rte_unused uint32_t pool) + struct ether_addr *mac_addr, + uint32_t index, + uint32_t pool) { - fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE); + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE, pool); + macvlan->mac_vmdq_id[index] = pool; } /* Remove a MAC address, and update filters */ @@ -1154,29 +1212,12 @@ static void fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) { struct rte_eth_dev_data *data = dev->data; - - if (index < FM10K_MAX_MACADDR_NUM) - fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, - FALSE); -} - -/* Remove all VLAN and MAC address table entries */ -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev) -{ - uint32_t j, k; struct fm10k_macvlan_filter_info *macvlan; macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) - fm10k_vlan_filter_set(dev, - j * FM10K_UINT32_BIT_SIZE + k, false); - } - } - } + fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, + FALSE, macvlan->mac_vmdq_id[index]); + macvlan->mac_vmdq_id[index] = 0; } static inline int @@ -2266,7 +2307,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) fm10k_mbx_unlock(hw); /* Add default mac address */ - fm10k_MAC_filter_set(dev, hw->mac.addr, true); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 3/4] fm10k: add VMDQ support in multi-queue configure 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He @ 2015-10-10 3:22 ` Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 4/4] doc: update release note for fm10k VMDQ support Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-10 3:22 UTC (permalink / raw) To: dev Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 23 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index cf48cd5..ed8d6a3 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -337,8 +337,43 @@ fm10k_dev_configure(struct rte_eth_dev *dev) return 0; } +/* fls = find last set bit = 32 minus the number of leading zeros */ +#ifndef fls +#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) +#endif + static void -fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +fm10k_dev_vmdq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + for (i = 0; i < vmdq_conf->nb_pool_maps; i++) { + if (!vmdq_conf->pool_map[i].pools) + continue; + fm10k_mbx_lock(hw); + fm10k_update_vlan(hw, vmdq_conf->pool_map[i].vlan_id, 0, true); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_pf_main_vsi_reset(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* Add default mac address */ + ether_addr_copy((const struct ether_addr *)hw->mac.addr, + &dev->data->mac_addrs[0]); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); +} + +static void +fm10k_dev_rss_configure(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_conf *dev_conf = &dev->data->dev_conf; @@ -409,6 +444,76 @@ fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) FM10K_WRITE_REG(hw, FM10K_MRQC(0), mrqc); } +static void +fm10k_dev_logic_port_update(struct rte_eth_dev *dev, + uint16_t nb_lport_old, uint16_t nb_lport_new) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t i; + + fm10k_mbx_lock(hw); + /* Disable previous logic ports */ + if (nb_lport_old) + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_old, false); + /* Enable new logic ports */ + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_new, true); + fm10k_mbx_unlock(hw); + + for (i = 0; i < nb_lport_new; i++) { + /* Set unicast mode by default. App can change + * to other mode in other API func. + */ + fm10k_mbx_lock(hw); + hw->mac.ops.update_xcast_mode(hw, hw->mac.dglort_map + i, + FM10K_XCAST_MODE_NONE); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + struct rte_eth_conf *dev_conf = &dev->data->dev_conf; + struct fm10k_macvlan_filter_info *macvlan; + uint16_t nb_queue_pools = 0; /* pool number in configuration */ + uint16_t nb_lport_new, nb_lport_old; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + fm10k_dev_rss_configure(dev); + + /* only PF supports VMDQ */ + if (hw->mac.type != fm10k_mac_pf) + return; + + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) + nb_queue_pools = vmdq_conf->nb_queue_pools; + + /* no pool number change, no need to update logic port and VLAN/MAC */ + if (macvlan->nb_queue_pools == nb_queue_pools) + return; + + nb_lport_old = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + nb_lport_new = nb_queue_pools ? nb_queue_pools : 1; + fm10k_dev_logic_port_update(dev, nb_lport_old, nb_lport_new); + + /* reset MAC/VLAN as it's based on VMDQ or PF main VSI */ + memset(dev->data->mac_addrs, 0, + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM); + memset(macvlan, 0, sizeof(*macvlan)); + macvlan->nb_queue_pools = nb_queue_pools; + + if (nb_queue_pools) + fm10k_dev_vmdq_rx_configure(dev); + else + fm10k_dev_pf_main_vsi_reset(dev); +} + static int fm10k_dev_tx_init(struct rte_eth_dev *dev) { @@ -517,7 +622,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) FM10K_WRITE_FLUSH(hw); } - /* Configure RSS if applicable */ + /* Configure VMDQ/RSS if applicable */ fm10k_dev_mq_rx_configure(dev); return 0; } @@ -747,10 +852,32 @@ fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast mode"); } -/* fls = find last set bit = 32 minus the number of leading zeros */ -#ifndef fls -#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) -#endif +static void +fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t dglortdec, pool_len, rss_len, i; + uint16_t nb_queue_pools; + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_queue_pools = macvlan->nb_queue_pools; + pool_len = nb_queue_pools ? fls(nb_queue_pools - 1) : 0; + rss_len = fls(dev->data->nb_rx_queues - 1) - pool_len; + dglortdec = (rss_len << FM10K_DGLORTDEC_RSSLENGTH_SHIFT) | pool_len; + + /* Establish only MAP 0 as valid */ + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); + + /* Configure VMDQ/RSS DGlort Decoder */ + FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), dglortdec); + + /* Invalidate all other GLORT entries */ + for (i = 1; i < FM10K_DGLORT_COUNT; i++) + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), + FM10K_DGLORTMAP_NONE); +} + #define BSIZEPKT_ROUNDUP ((1 << FM10K_SRRCTL_BSIZEPKT_SHIFT) - 1) static int fm10k_dev_start(struct rte_eth_dev *dev) @@ -791,20 +918,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) return diag; } - if (hw->mac.type == fm10k_mac_pf) { - /* Establish only VSI 0 as valid */ - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); - - /* Configure RSS bits used in RETA table */ - FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), - fls(dev->data->nb_rx_queues - 1) << - FM10K_DGLORTDEC_RSSLENGTH_SHIFT); - - /* Invalidate all other GLORT entries */ - for (i = 1; i < FM10K_DGLORT_COUNT; i++) - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), - FM10K_DGLORTMAP_NONE); - } + if (hw->mac.type == fm10k_mac_pf) + fm10k_dev_dglort_map_configure(dev); for (i = 0; i < dev->data->nb_rx_queues; i++) { struct fm10k_rx_queue *rxq; @@ -838,8 +953,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) } } - /* Update default vlan */ - if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) + /* Update default vlan when not in VMDQ mode */ + if (!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG)) fm10k_vlan_filter_set(dev, hw->mac.default_vid, true); return 0; @@ -978,7 +1093,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM; dev_info->max_hash_mac_addrs = 0; dev_info->max_vfs = dev->pci_dev->max_vfs; - dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->vmdq_pool_base = 0; + 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_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | DEV_RX_OFFLOAD_IPV4_CKSUM | -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 4/4] doc: update release note for fm10k VMDQ support 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He ` (2 preceding siblings ...) 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He @ 2015-10-10 3:22 ` Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-10 3:22 UTC (permalink / raw) To: dev Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- doc/guides/rel_notes/release_2_2.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 5687676..278149f 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -4,6 +4,11 @@ DPDK Release 2.2 New Features ------------ +* **fm10k: Added VMDQ support.** + + Added functions to configure VMDQ mode and add MAC address for each VMDQ + queue pool. Also included logic to do sanity check for multi-queue settings. + Resolved Issues --------------- -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 0/4] fm10k: add VMDQ support 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He ` (3 preceding siblings ...) 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 4/4] doc: update release note for fm10k VMDQ support Shaopeng He @ 2015-10-27 9:21 ` Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 1/4] fm10k: add multi-queue checking Shaopeng He ` (6 more replies) 4 siblings, 7 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-27 9:21 UTC (permalink / raw) To: dev This patch series adds VMDQ support for fm10k. It includes the functions to configure VMDQ mode and add MAC address for each VMDQ queue pool. It also includes logic to do sanity check for multi-queue settings. Changes in v3: - Keep device default MAC address even in VMDQ mode after queue pool config was changed, because some applications (e.g. vmdq_app) always need a valid MAC address there. Changes in v2: - Reword some comments and commit messages - Updated release note Shaopeng He (4): fm10k: add multi-queue checking fm10k: add VMDQ support in MAC/VLAN filter fm10k: add VMDQ support in multi-queue configure doc: update release note for fm10k VMDQ support doc/guides/rel_notes/release_2_2.rst | 5 + drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 358 +++++++++++++++++++++++++++-------- 3 files changed, 289 insertions(+), 77 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 1/4] fm10k: add multi-queue checking 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He @ 2015-10-27 9:21 ` Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He ` (5 subsequent siblings) 6 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-27 9:21 UTC (permalink / raw) To: dev Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index a69c990..082937d 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) } static int +fm10k_check_mq_mode(struct rte_eth_dev *dev) +{ + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint16_t nb_rx_q = dev->data->nb_rx_queues; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { + PMD_INIT_LOG(ERR, "DCB mode is not supported."); + return -EINVAL; + } + + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) + return 0; + + if (hw->mac.type == fm10k_mac_vf) { + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); + return -EINVAL; + } + + /* Check VMDQ queue pool number */ + if (vmdq_conf->nb_queue_pools > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT || + vmdq_conf->nb_queue_pools > nb_rx_q) { + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", + vmdq_conf->nb_queue_pools); + return -EINVAL; + } + + return 0; +} + +static int fm10k_dev_configure(struct rte_eth_dev *dev) { + int ret; + PMD_INIT_FUNC_TRACE(); if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); + /* multipe queue mode checking */ + ret = fm10k_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", + ret); + return ret; + } return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 1/4] fm10k: add multi-queue checking Shaopeng He @ 2015-10-27 9:21 ` Shaopeng He 2015-10-30 16:17 ` Thomas Monjalon 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He ` (4 subsequent siblings) 6 siblings, 1 reply; 27+ messages in thread From: Shaopeng He @ 2015-10-27 9:21 UTC (permalink / raw) To: dev The patch does below things for fm10k MAC/VLAN filter: - Add separate functions for VMDQ and main VSI to change MAC filter. - Disable modification to VLAN filter in VMDQ mode. - In device close phase, delete logic ports to remove all MAC/VLAN filters belonging to those ports. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++-------------- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index c089882..439e95f 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -126,6 +126,9 @@ struct fm10k_macvlan_filter_info { uint16_t vlan_num; /* Total VLAN number */ uint16_t mac_num; /* Total mac number */ + uint16_t nb_queue_pools; /* Active queue pools number */ + /* VMDQ ID for each MAC address */ + uint8_t mac_vmdq_id[FM10K_MAX_MACADDR_NUM]; uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */ }; diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 082937d..cf48cd5 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -45,6 +45,8 @@ #define FM10K_MBXLOCK_DELAY_US 20 #define UINT64_LOWER_32BITS_MASK 0x00000000ffffffffULL +#define MAIN_VSI_POOL_NUMBER 0 + /* Max try times to acquire switch status */ #define MAX_QUERY_SWITCH_STATE_TIMES 10 /* Wait interval to get switch status */ @@ -61,10 +63,8 @@ static void fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev); static inline int fm10k_glort_valid(struct fm10k_hw *hw); static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add); -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev); +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool); static void fm10k_tx_queue_release(void *queue); static void fm10k_rx_queue_release(void *queue); @@ -883,10 +883,17 @@ static void fm10k_dev_close(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint16_t nb_lport; + struct fm10k_macvlan_filter_info *macvlan; PMD_INIT_FUNC_TRACE(); - fm10k_MACVLAN_remove_all(dev); + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_lport = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + fm10k_mbx_lock(hw); + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport, false); + fm10k_mbx_unlock(hw); /* Stop mailbox service first */ fm10k_close_mbx_service(hw); @@ -1023,6 +1030,11 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + if (macvlan->nb_queue_pools > 0) { /* VMDQ mode */ + PMD_INIT_LOG(ERR, "Cannot change VLAN filter in VMDQ mode"); + return (-EINVAL); + } + if (vlan_id > ETH_VLAN_ID_MAX) { PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096"); return (-EINVAL); @@ -1100,38 +1112,80 @@ fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) } } -/* Add/Remove a MAC address, and update filters */ -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) +/* Add/Remove a MAC address, and update filters to main VSI */ +static void fm10k_MAC_filter_set_main_vsi(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) { - uint32_t i, j, k; - struct fm10k_hw *hw; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct fm10k_macvlan_filter_info *macvlan; + uint32_t i, j, k; - hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - i = 0; - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) { - if (i + 1 > macvlan->vlan_num) { - PMD_INIT_LOG(ERR, "vlan number " - "not match"); - return; - } - fm10k_mbx_lock(hw); - fm10k_update_uc_addr(hw, - hw->mac.dglort_map, mac, - j * FM10K_UINT32_BIT_SIZE + k, - add, 0); - fm10k_mbx_unlock(hw); - i++; - } + if (pool != MAIN_VSI_POOL_NUMBER) { + PMD_DRV_LOG(ERR, "VMDQ not enabled, can't set " + "mac to pool %u", pool); + return; + } + for (i = 0, j = 0; j < FM10K_VFTA_SIZE; j++) { + if (!macvlan->vfta[j]) + continue; + for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { + if (!(macvlan->vfta[j] & (1 << k))) + continue; + if (i + 1 > macvlan->vlan_num) { + PMD_INIT_LOG(ERR, "vlan number not match"); + return; } + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map, mac, + j * FM10K_UINT32_BIT_SIZE + k, add, 0); + fm10k_mbx_unlock(hw); + i++; } } +} + +/* Add/Remove a MAC address, and update filters to VMDQ */ +static void fm10k_MAC_filter_set_vmdq(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct fm10k_macvlan_filter_info *macvlan; + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (pool > macvlan->nb_queue_pools) { + PMD_DRV_LOG(ERR, "Pool number %u invalid." + " Max pool is %u", + pool, macvlan->nb_queue_pools); + return; + } + for (i = 0; i < (int)vmdq_conf->nb_pool_maps; i++) { + if (!(vmdq_conf->pool_map[i].pools & (1UL << pool))) + continue; + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map + pool, mac, + vmdq_conf->pool_map[i].vlan_id, add, 0); + fm10k_mbx_unlock(hw); + } +} + +/* Add/Remove a MAC address, and update filters */ +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + + if (macvlan->nb_queue_pools > 0) /* VMDQ mode */ + fm10k_MAC_filter_set_vmdq(dev, mac, add, pool); + else + fm10k_MAC_filter_set_main_vsi(dev, mac, add, pool); if (add) macvlan->mac_num++; @@ -1142,11 +1196,15 @@ fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) /* Add a MAC address, and update filters */ static void fm10k_macaddr_add(struct rte_eth_dev *dev, - struct ether_addr *mac_addr, - __rte_unused uint32_t index, - __rte_unused uint32_t pool) + struct ether_addr *mac_addr, + uint32_t index, + uint32_t pool) { - fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE); + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE, pool); + macvlan->mac_vmdq_id[index] = pool; } /* Remove a MAC address, and update filters */ @@ -1154,29 +1212,12 @@ static void fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) { struct rte_eth_dev_data *data = dev->data; - - if (index < FM10K_MAX_MACADDR_NUM) - fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, - FALSE); -} - -/* Remove all VLAN and MAC address table entries */ -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev) -{ - uint32_t j, k; struct fm10k_macvlan_filter_info *macvlan; macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) - fm10k_vlan_filter_set(dev, - j * FM10K_UINT32_BIT_SIZE + k, false); - } - } - } + fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, + FALSE, macvlan->mac_vmdq_id[index]); + macvlan->mac_vmdq_id[index] = 0; } static inline int @@ -2266,7 +2307,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) fm10k_mbx_unlock(hw); /* Add default mac address */ - fm10k_MAC_filter_set(dev, hw->mac.addr, true); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He @ 2015-10-30 16:17 ` Thomas Monjalon 2015-10-31 2:22 ` He, Shaopeng 0 siblings, 1 reply; 27+ messages in thread From: Thomas Monjalon @ 2015-10-30 16:17 UTC (permalink / raw) To: Shaopeng He; +Cc: dev Sorry it does not compile with clang. 2015-10-27 17:21, Shaopeng He: > + for (i = 0; i < (int)vmdq_conf->nb_pool_maps; i++) { fm10k_ethdev.c:1168:16: error: comparison of integers of different signs: 'uint32_t' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter 2015-10-30 16:17 ` Thomas Monjalon @ 2015-10-31 2:22 ` He, Shaopeng 0 siblings, 0 replies; 27+ messages in thread From: He, Shaopeng @ 2015-10-31 2:22 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev Hi, Thomas > -----Original Message----- > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com] > Sent: Saturday, October 31, 2015 12:18 AM > To: He, Shaopeng > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in > MAC/VLAN filter > > Sorry it does not compile with clang. > > 2015-10-27 17:21, Shaopeng He: > > + for (i = 0; i < (int)vmdq_conf->nb_pool_maps; i++) { > > fm10k_ethdev.c:1168:16: error: comparison of integers of different signs: > 'uint32_t' (aka 'unsigned int') and 'int' [-Werror,-Wsign-compare] Thanks for the comments, I will send another version ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 3/4] fm10k: add VMDQ support in multi-queue configure 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He @ 2015-10-27 9:21 ` Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 4/4] doc: update release note for fm10k VMDQ support Shaopeng He ` (3 subsequent siblings) 6 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-27 9:21 UTC (permalink / raw) To: dev Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 23 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index cf48cd5..8c31391 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -337,8 +337,41 @@ fm10k_dev_configure(struct rte_eth_dev *dev) return 0; } +/* fls = find last set bit = 32 minus the number of leading zeros */ +#ifndef fls +#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) +#endif + static void -fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +fm10k_dev_vmdq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + for (i = 0; i < vmdq_conf->nb_pool_maps; i++) { + if (!vmdq_conf->pool_map[i].pools) + continue; + fm10k_mbx_lock(hw); + fm10k_update_vlan(hw, vmdq_conf->pool_map[i].vlan_id, 0, true); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_pf_main_vsi_reset(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* Add default mac address */ + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); +} + +static void +fm10k_dev_rss_configure(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_conf *dev_conf = &dev->data->dev_conf; @@ -409,6 +442,78 @@ fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) FM10K_WRITE_REG(hw, FM10K_MRQC(0), mrqc); } +static void +fm10k_dev_logic_port_update(struct rte_eth_dev *dev, + uint16_t nb_lport_old, uint16_t nb_lport_new) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t i; + + fm10k_mbx_lock(hw); + /* Disable previous logic ports */ + if (nb_lport_old) + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_old, false); + /* Enable new logic ports */ + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_new, true); + fm10k_mbx_unlock(hw); + + for (i = 0; i < nb_lport_new; i++) { + /* Set unicast mode by default. App can change + * to other mode in other API func. + */ + fm10k_mbx_lock(hw); + hw->mac.ops.update_xcast_mode(hw, hw->mac.dglort_map + i, + FM10K_XCAST_MODE_NONE); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + struct rte_eth_conf *dev_conf = &dev->data->dev_conf; + struct fm10k_macvlan_filter_info *macvlan; + uint16_t nb_queue_pools = 0; /* pool number in configuration */ + uint16_t nb_lport_new, nb_lport_old; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + fm10k_dev_rss_configure(dev); + + /* only PF supports VMDQ */ + if (hw->mac.type != fm10k_mac_pf) + return; + + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) + nb_queue_pools = vmdq_conf->nb_queue_pools; + + /* no pool number change, no need to update logic port and VLAN/MAC */ + if (macvlan->nb_queue_pools == nb_queue_pools) + return; + + nb_lport_old = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + nb_lport_new = nb_queue_pools ? nb_queue_pools : 1; + fm10k_dev_logic_port_update(dev, nb_lport_old, nb_lport_new); + + /* reset MAC/VLAN as it's based on VMDQ or PF main VSI */ + memset(dev->data->mac_addrs, 0, + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM); + ether_addr_copy((const struct ether_addr *)hw->mac.addr, + &dev->data->mac_addrs[0]); + memset(macvlan, 0, sizeof(*macvlan)); + macvlan->nb_queue_pools = nb_queue_pools; + + if (nb_queue_pools) + fm10k_dev_vmdq_rx_configure(dev); + else + fm10k_dev_pf_main_vsi_reset(dev); +} + static int fm10k_dev_tx_init(struct rte_eth_dev *dev) { @@ -517,7 +622,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) FM10K_WRITE_FLUSH(hw); } - /* Configure RSS if applicable */ + /* Configure VMDQ/RSS if applicable */ fm10k_dev_mq_rx_configure(dev); return 0; } @@ -747,10 +852,32 @@ fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast mode"); } -/* fls = find last set bit = 32 minus the number of leading zeros */ -#ifndef fls -#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) -#endif +static void +fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t dglortdec, pool_len, rss_len, i; + uint16_t nb_queue_pools; + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_queue_pools = macvlan->nb_queue_pools; + pool_len = nb_queue_pools ? fls(nb_queue_pools - 1) : 0; + rss_len = fls(dev->data->nb_rx_queues - 1) - pool_len; + dglortdec = (rss_len << FM10K_DGLORTDEC_RSSLENGTH_SHIFT) | pool_len; + + /* Establish only MAP 0 as valid */ + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); + + /* Configure VMDQ/RSS DGlort Decoder */ + FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), dglortdec); + + /* Invalidate all other GLORT entries */ + for (i = 1; i < FM10K_DGLORT_COUNT; i++) + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), + FM10K_DGLORTMAP_NONE); +} + #define BSIZEPKT_ROUNDUP ((1 << FM10K_SRRCTL_BSIZEPKT_SHIFT) - 1) static int fm10k_dev_start(struct rte_eth_dev *dev) @@ -791,20 +918,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) return diag; } - if (hw->mac.type == fm10k_mac_pf) { - /* Establish only VSI 0 as valid */ - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); - - /* Configure RSS bits used in RETA table */ - FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), - fls(dev->data->nb_rx_queues - 1) << - FM10K_DGLORTDEC_RSSLENGTH_SHIFT); - - /* Invalidate all other GLORT entries */ - for (i = 1; i < FM10K_DGLORT_COUNT; i++) - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), - FM10K_DGLORTMAP_NONE); - } + if (hw->mac.type == fm10k_mac_pf) + fm10k_dev_dglort_map_configure(dev); for (i = 0; i < dev->data->nb_rx_queues; i++) { struct fm10k_rx_queue *rxq; @@ -838,8 +953,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) } } - /* Update default vlan */ - if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) + /* Update default vlan when not in VMDQ mode */ + if (!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG)) fm10k_vlan_filter_set(dev, hw->mac.default_vid, true); return 0; @@ -978,7 +1093,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM; dev_info->max_hash_mac_addrs = 0; dev_info->max_vfs = dev->pci_dev->max_vfs; - dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->vmdq_pool_base = 0; + 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_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | DEV_RX_OFFLOAD_IPV4_CKSUM | -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 4/4] doc: update release note for fm10k VMDQ support 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He ` (2 preceding siblings ...) 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He @ 2015-10-27 9:21 ` Shaopeng He 2015-10-30 4:42 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Wu, Jingjing ` (2 subsequent siblings) 6 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-27 9:21 UTC (permalink / raw) To: dev Signed-off-by: Shaopeng He <shaopeng.he@intel.com> --- doc/guides/rel_notes/release_2_2.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 5687676..278149f 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -4,6 +4,11 @@ DPDK Release 2.2 New Features ------------ +* **fm10k: Added VMDQ support.** + + Added functions to configure VMDQ mode and add MAC address for each VMDQ + queue pool. Also included logic to do sanity check for multi-queue settings. + Resolved Issues --------------- -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/4] fm10k: add VMDQ support 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He ` (3 preceding siblings ...) 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 4/4] doc: update release note for fm10k VMDQ support Shaopeng He @ 2015-10-30 4:42 ` Wu, Jingjing 2015-10-30 14:07 ` Qiu, Michael 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He 6 siblings, 0 replies; 27+ messages in thread From: Wu, Jingjing @ 2015-10-30 4:42 UTC (permalink / raw) To: He, Shaopeng, dev > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shaopeng He > Sent: Tuesday, October 27, 2015 5:22 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v3 0/4] fm10k: add VMDQ support > > This patch series adds VMDQ support for fm10k. > It includes the functions to configure VMDQ mode and add MAC address for > each VMDQ queue pool. > It also includes logic to do sanity check for multi-queue settings. > > Changes in v3: > - Keep device default MAC address even in VMDQ mode after > queue pool config was changed, because some applications > (e.g. vmdq_app) always need a valid MAC address there. > > Changes in v2: > - Reword some comments and commit messages > - Updated release note > > Shaopeng He (4): > fm10k: add multi-queue checking > fm10k: add VMDQ support in MAC/VLAN filter > fm10k: add VMDQ support in multi-queue configure > doc: update release note for fm10k VMDQ support > > doc/guides/rel_notes/release_2_2.rst | 5 + > drivers/net/fm10k/fm10k.h | 3 + > drivers/net/fm10k/fm10k_ethdev.c | 358 > +++++++++++++++++++++++++++-------- > 3 files changed, 289 insertions(+), 77 deletions(-) > > -- > 1.9.3 Acked-by: Jingjing Wu <jingjing.wu@intel.com> ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/4] fm10k: add VMDQ support 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He ` (4 preceding siblings ...) 2015-10-30 4:42 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Wu, Jingjing @ 2015-10-30 14:07 ` Qiu, Michael 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He 6 siblings, 0 replies; 27+ messages in thread From: Qiu, Michael @ 2015-10-30 14:07 UTC (permalink / raw) To: He, Shaopeng, dev On 2015/10/27 17:25, He, Shaopeng wrote: > This patch series adds VMDQ support for fm10k. > It includes the functions to configure VMDQ mode and > add MAC address for each VMDQ queue pool. > It also includes logic to do sanity check for > multi-queue settings. > > Changes in v3: > - Keep device default MAC address even in VMDQ mode after > queue pool config was changed, because some applications > (e.g. vmdq_app) always need a valid MAC address there. > > Changes in v2: > - Reword some comments and commit messages > - Updated release note > > Shaopeng He (4): > fm10k: add multi-queue checking > fm10k: add VMDQ support in MAC/VLAN filter > fm10k: add VMDQ support in multi-queue configure > doc: update release note for fm10k VMDQ support > > doc/guides/rel_notes/release_2_2.rst | 5 + > drivers/net/fm10k/fm10k.h | 3 + > drivers/net/fm10k/fm10k_ethdev.c | 358 +++++++++++++++++++++++++++-------- > 3 files changed, 289 insertions(+), 77 deletions(-) > Acked-by: Michael Qiu <michael.qiu@intel.com> ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v4 0/4] fm10k: add VMDQ support 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He ` (5 preceding siblings ...) 2015-10-30 14:07 ` Qiu, Michael @ 2015-10-31 2:44 ` Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 1/4] fm10k: add multi-queue checking Shaopeng He ` (4 more replies) 6 siblings, 5 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-31 2:44 UTC (permalink / raw) To: dev This patch series adds VMDQ support for fm10k. It includes the functions to configure VMDQ mode and add MAC address for each VMDQ queue pool. It also includes logic to do sanity check for multi-queue settings. Changes in v4: - Fix a clang compile issue - Rebase to latest code Changes in v3: - Keep device default MAC address even in VMDQ mode after queue pool config was changed, because some applications (e.g. vmdq_app) always need a valid MAC address there Changes in v2: - Reword some comments and commit messages - Update release note Shaopeng He (4): fm10k: add multi-queue checking fm10k: add VMDQ support in MAC/VLAN filter fm10k: add VMDQ support in multi-queue configure doc: update release note for fm10k VMDQ support doc/guides/rel_notes/release_2_2.rst | 5 + drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 358 +++++++++++++++++++++++++++-------- 3 files changed, 289 insertions(+), 77 deletions(-) -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v4 1/4] fm10k: add multi-queue checking 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He @ 2015-10-31 2:44 ` Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He ` (3 subsequent siblings) 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-31 2:44 UTC (permalink / raw) To: dev Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> Acked-by: Jingjing Wu <jingjing.wu@intel.com> Acked-by: Michael Qiu <michael.qiu@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index b104fc2..75d1fa3 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) } static int +fm10k_check_mq_mode(struct rte_eth_dev *dev) +{ + enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint16_t nb_rx_q = dev->data->nb_rx_queues; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { + PMD_INIT_LOG(ERR, "DCB mode is not supported."); + return -EINVAL; + } + + if (!(rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG)) + return 0; + + if (hw->mac.type == fm10k_mac_vf) { + PMD_INIT_LOG(ERR, "VMDQ mode is not supported in VF."); + return -EINVAL; + } + + /* Check VMDQ queue pool number */ + if (vmdq_conf->nb_queue_pools > + sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT || + vmdq_conf->nb_queue_pools > nb_rx_q) { + PMD_INIT_LOG(ERR, "Too many of queue pools: %d", + vmdq_conf->nb_queue_pools); + return -EINVAL; + } + + return 0; +} + +static int fm10k_dev_configure(struct rte_eth_dev *dev) { + int ret; + PMD_INIT_FUNC_TRACE(); if (dev->data->dev_conf.rxmode.hw_strip_crc == 0) PMD_INIT_LOG(WARNING, "fm10k always strip CRC"); + /* multipe queue mode checking */ + ret = fm10k_check_mq_mode(dev); + if (ret != 0) { + PMD_DRV_LOG(ERR, "fm10k_check_mq_mode fails with %d.", + ret); + return ret; + } return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v4 2/4] fm10k: add VMDQ support in MAC/VLAN filter 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 1/4] fm10k: add multi-queue checking Shaopeng He @ 2015-10-31 2:44 ` Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He ` (2 subsequent siblings) 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-31 2:44 UTC (permalink / raw) To: dev The patch does below things for fm10k MAC/VLAN filter: - Add separate functions for VMDQ and main VSI to change MAC filter. - Disable modification to VLAN filter in VMDQ mode. - In device close phase, delete logic ports to remove all MAC/VLAN filters belonging to those ports. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> Acked-by: Jingjing Wu <jingjing.wu@intel.com> Acked-by: Michael Qiu <michael.qiu@intel.com> --- drivers/net/fm10k/fm10k.h | 3 + drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++-------------- 2 files changed, 99 insertions(+), 54 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index c089882..439e95f 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -126,6 +126,9 @@ struct fm10k_macvlan_filter_info { uint16_t vlan_num; /* Total VLAN number */ uint16_t mac_num; /* Total mac number */ + uint16_t nb_queue_pools; /* Active queue pools number */ + /* VMDQ ID for each MAC address */ + uint8_t mac_vmdq_id[FM10K_MAX_MACADDR_NUM]; uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */ }; diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 75d1fa3..76c050a 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -45,6 +45,8 @@ #define FM10K_MBXLOCK_DELAY_US 20 #define UINT64_LOWER_32BITS_MASK 0x00000000ffffffffULL +#define MAIN_VSI_POOL_NUMBER 0 + /* Max try times to acquire switch status */ #define MAX_QUERY_SWITCH_STATE_TIMES 10 /* Wait interval to get switch status */ @@ -61,10 +63,8 @@ static void fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev); static inline int fm10k_glort_valid(struct fm10k_hw *hw); static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on); -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add); -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev); +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool); static void fm10k_tx_queue_release(void *queue); static void fm10k_rx_queue_release(void *queue); @@ -883,10 +883,17 @@ static void fm10k_dev_close(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint16_t nb_lport; + struct fm10k_macvlan_filter_info *macvlan; PMD_INIT_FUNC_TRACE(); - fm10k_MACVLAN_remove_all(dev); + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_lport = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + fm10k_mbx_lock(hw); + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport, false); + fm10k_mbx_unlock(hw); /* Stop mailbox service first */ fm10k_close_mbx_service(hw); @@ -1024,6 +1031,11 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + if (macvlan->nb_queue_pools > 0) { /* VMDQ mode */ + PMD_INIT_LOG(ERR, "Cannot change VLAN filter in VMDQ mode"); + return (-EINVAL); + } + if (vlan_id > ETH_VLAN_ID_MAX) { PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096"); return (-EINVAL); @@ -1101,38 +1113,80 @@ fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) } } -/* Add/Remove a MAC address, and update filters */ -static void -fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) +/* Add/Remove a MAC address, and update filters to main VSI */ +static void fm10k_MAC_filter_set_main_vsi(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) { - uint32_t i, j, k; - struct fm10k_hw *hw; + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct fm10k_macvlan_filter_info *macvlan; + uint32_t i, j, k; - hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - i = 0; - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) { - if (i + 1 > macvlan->vlan_num) { - PMD_INIT_LOG(ERR, "vlan number " - "not match"); - return; - } - fm10k_mbx_lock(hw); - fm10k_update_uc_addr(hw, - hw->mac.dglort_map, mac, - j * FM10K_UINT32_BIT_SIZE + k, - add, 0); - fm10k_mbx_unlock(hw); - i++; - } + if (pool != MAIN_VSI_POOL_NUMBER) { + PMD_DRV_LOG(ERR, "VMDQ not enabled, can't set " + "mac to pool %u", pool); + return; + } + for (i = 0, j = 0; j < FM10K_VFTA_SIZE; j++) { + if (!macvlan->vfta[j]) + continue; + for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { + if (!(macvlan->vfta[j] & (1 << k))) + continue; + if (i + 1 > macvlan->vlan_num) { + PMD_INIT_LOG(ERR, "vlan number not match"); + return; } + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map, mac, + j * FM10K_UINT32_BIT_SIZE + k, add, 0); + fm10k_mbx_unlock(hw); + i++; } } +} + +/* Add/Remove a MAC address, and update filters to VMDQ */ +static void fm10k_MAC_filter_set_vmdq(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct fm10k_macvlan_filter_info *macvlan; + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + if (pool > macvlan->nb_queue_pools) { + PMD_DRV_LOG(ERR, "Pool number %u invalid." + " Max pool is %u", + pool, macvlan->nb_queue_pools); + return; + } + for (i = 0; i < vmdq_conf->nb_pool_maps; i++) { + if (!(vmdq_conf->pool_map[i].pools & (1UL << pool))) + continue; + fm10k_mbx_lock(hw); + fm10k_update_uc_addr(hw, hw->mac.dglort_map + pool, mac, + vmdq_conf->pool_map[i].vlan_id, add, 0); + fm10k_mbx_unlock(hw); + } +} + +/* Add/Remove a MAC address, and update filters */ +static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, + const u8 *mac, bool add, uint32_t pool) +{ + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + + if (macvlan->nb_queue_pools > 0) /* VMDQ mode */ + fm10k_MAC_filter_set_vmdq(dev, mac, add, pool); + else + fm10k_MAC_filter_set_main_vsi(dev, mac, add, pool); if (add) macvlan->mac_num++; @@ -1143,11 +1197,15 @@ fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add) /* Add a MAC address, and update filters */ static void fm10k_macaddr_add(struct rte_eth_dev *dev, - struct ether_addr *mac_addr, - __rte_unused uint32_t index, - __rte_unused uint32_t pool) + struct ether_addr *mac_addr, + uint32_t index, + uint32_t pool) { - fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE); + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE, pool); + macvlan->mac_vmdq_id[index] = pool; } /* Remove a MAC address, and update filters */ @@ -1155,29 +1213,12 @@ static void fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index) { struct rte_eth_dev_data *data = dev->data; - - if (index < FM10K_MAX_MACADDR_NUM) - fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, - FALSE); -} - -/* Remove all VLAN and MAC address table entries */ -static void -fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev) -{ - uint32_t j, k; struct fm10k_macvlan_filter_info *macvlan; macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); - for (j = 0; j < FM10K_VFTA_SIZE; j++) { - if (macvlan->vfta[j]) { - for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) { - if (macvlan->vfta[j] & (1 << k)) - fm10k_vlan_filter_set(dev, - j * FM10K_UINT32_BIT_SIZE + k, false); - } - } - } + fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes, + FALSE, macvlan->mac_vmdq_id[index]); + macvlan->mac_vmdq_id[index] = 0; } static inline int @@ -2267,7 +2308,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev) fm10k_mbx_unlock(hw); /* Add default mac address */ - fm10k_MAC_filter_set(dev, hw->mac.addr, true); + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); return 0; } -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v4 3/4] fm10k: add VMDQ support in multi-queue configure 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He @ 2015-10-31 2:44 ` Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 4/4] doc: update release note for fm10k VMDQ support Shaopeng He 2015-11-01 15:15 ` [dpdk-dev] [PATCH v4 0/4] fm10k: add " Thomas Monjalon 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-31 2:44 UTC (permalink / raw) To: dev Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed. Signed-off-by: Shaopeng He <shaopeng.he@intel.com> Acked-by: Jingjing Wu <jingjing.wu@intel.com> Acked-by: Michael Qiu <michael.qiu@intel.com> --- drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 23 deletions(-) diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 76c050a..941dae7 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -337,8 +337,41 @@ fm10k_dev_configure(struct rte_eth_dev *dev) return 0; } +/* fls = find last set bit = 32 minus the number of leading zeros */ +#ifndef fls +#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) +#endif + static void -fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +fm10k_dev_vmdq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + uint32_t i; + + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + for (i = 0; i < vmdq_conf->nb_pool_maps; i++) { + if (!vmdq_conf->pool_map[i].pools) + continue; + fm10k_mbx_lock(hw); + fm10k_update_vlan(hw, vmdq_conf->pool_map[i].vlan_id, 0, true); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_pf_main_vsi_reset(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + /* Add default mac address */ + fm10k_MAC_filter_set(dev, hw->mac.addr, true, + MAIN_VSI_POOL_NUMBER); +} + +static void +fm10k_dev_rss_configure(struct rte_eth_dev *dev) { struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_conf *dev_conf = &dev->data->dev_conf; @@ -409,6 +442,78 @@ fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) FM10K_WRITE_REG(hw, FM10K_MRQC(0), mrqc); } +static void +fm10k_dev_logic_port_update(struct rte_eth_dev *dev, + uint16_t nb_lport_old, uint16_t nb_lport_new) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t i; + + fm10k_mbx_lock(hw); + /* Disable previous logic ports */ + if (nb_lport_old) + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_old, false); + /* Enable new logic ports */ + hw->mac.ops.update_lport_state(hw, hw->mac.dglort_map, + nb_lport_new, true); + fm10k_mbx_unlock(hw); + + for (i = 0; i < nb_lport_new; i++) { + /* Set unicast mode by default. App can change + * to other mode in other API func. + */ + fm10k_mbx_lock(hw); + hw->mac.ops.update_xcast_mode(hw, hw->mac.dglort_map + i, + FM10K_XCAST_MODE_NONE); + fm10k_mbx_unlock(hw); + } +} + +static void +fm10k_dev_mq_rx_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + struct rte_eth_vmdq_rx_conf *vmdq_conf; + struct rte_eth_conf *dev_conf = &dev->data->dev_conf; + struct fm10k_macvlan_filter_info *macvlan; + uint16_t nb_queue_pools = 0; /* pool number in configuration */ + uint16_t nb_lport_new, nb_lport_old; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + vmdq_conf = &dev->data->dev_conf.rx_adv_conf.vmdq_rx_conf; + + fm10k_dev_rss_configure(dev); + + /* only PF supports VMDQ */ + if (hw->mac.type != fm10k_mac_pf) + return; + + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG) + nb_queue_pools = vmdq_conf->nb_queue_pools; + + /* no pool number change, no need to update logic port and VLAN/MAC */ + if (macvlan->nb_queue_pools == nb_queue_pools) + return; + + nb_lport_old = macvlan->nb_queue_pools ? macvlan->nb_queue_pools : 1; + nb_lport_new = nb_queue_pools ? nb_queue_pools : 1; + fm10k_dev_logic_port_update(dev, nb_lport_old, nb_lport_new); + + /* reset MAC/VLAN as it's based on VMDQ or PF main VSI */ + memset(dev->data->mac_addrs, 0, + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM); + ether_addr_copy((const struct ether_addr *)hw->mac.addr, + &dev->data->mac_addrs[0]); + memset(macvlan, 0, sizeof(*macvlan)); + macvlan->nb_queue_pools = nb_queue_pools; + + if (nb_queue_pools) + fm10k_dev_vmdq_rx_configure(dev); + else + fm10k_dev_pf_main_vsi_reset(dev); +} + static int fm10k_dev_tx_init(struct rte_eth_dev *dev) { @@ -517,7 +622,7 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev) FM10K_WRITE_FLUSH(hw); } - /* Configure RSS if applicable */ + /* Configure VMDQ/RSS if applicable */ fm10k_dev_mq_rx_configure(dev); return 0; } @@ -747,10 +852,32 @@ fm10k_dev_allmulticast_disable(struct rte_eth_dev *dev) PMD_INIT_LOG(ERR, "Failed to disable allmulticast mode"); } -/* fls = find last set bit = 32 minus the number of leading zeros */ -#ifndef fls -#define fls(x) (((x) == 0) ? 0 : (32 - __builtin_clz((x)))) -#endif +static void +fm10k_dev_dglort_map_configure(struct rte_eth_dev *dev) +{ + struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private); + uint32_t dglortdec, pool_len, rss_len, i; + uint16_t nb_queue_pools; + struct fm10k_macvlan_filter_info *macvlan; + + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private); + nb_queue_pools = macvlan->nb_queue_pools; + pool_len = nb_queue_pools ? fls(nb_queue_pools - 1) : 0; + rss_len = fls(dev->data->nb_rx_queues - 1) - pool_len; + dglortdec = (rss_len << FM10K_DGLORTDEC_RSSLENGTH_SHIFT) | pool_len; + + /* Establish only MAP 0 as valid */ + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); + + /* Configure VMDQ/RSS DGlort Decoder */ + FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), dglortdec); + + /* Invalidate all other GLORT entries */ + for (i = 1; i < FM10K_DGLORT_COUNT; i++) + FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), + FM10K_DGLORTMAP_NONE); +} + #define BSIZEPKT_ROUNDUP ((1 << FM10K_SRRCTL_BSIZEPKT_SHIFT) - 1) static int fm10k_dev_start(struct rte_eth_dev *dev) @@ -791,20 +918,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) return diag; } - if (hw->mac.type == fm10k_mac_pf) { - /* Establish only VSI 0 as valid */ - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(0), FM10K_DGLORTMAP_ANY); - - /* Configure RSS bits used in RETA table */ - FM10K_WRITE_REG(hw, FM10K_DGLORTDEC(0), - fls(dev->data->nb_rx_queues - 1) << - FM10K_DGLORTDEC_RSSLENGTH_SHIFT); - - /* Invalidate all other GLORT entries */ - for (i = 1; i < FM10K_DGLORT_COUNT; i++) - FM10K_WRITE_REG(hw, FM10K_DGLORTMAP(i), - FM10K_DGLORTMAP_NONE); - } + if (hw->mac.type == fm10k_mac_pf) + fm10k_dev_dglort_map_configure(dev); for (i = 0; i < dev->data->nb_rx_queues; i++) { struct fm10k_rx_queue *rxq; @@ -838,8 +953,8 @@ fm10k_dev_start(struct rte_eth_dev *dev) } } - /* Update default vlan */ - if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) + /* Update default vlan when not in VMDQ mode */ + if (!(dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_VMDQ_FLAG)) fm10k_vlan_filter_set(dev, hw->mac.default_vid, true); return 0; @@ -978,7 +1093,10 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev, dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM; dev_info->max_hash_mac_addrs = 0; dev_info->max_vfs = dev->pci_dev->max_vfs; - dev_info->max_vmdq_pools = ETH_64_POOLS; + dev_info->vmdq_pool_base = 0; + 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_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP | DEV_RX_OFFLOAD_IPV4_CKSUM | -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v4 4/4] doc: update release note for fm10k VMDQ support 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He ` (2 preceding siblings ...) 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He @ 2015-10-31 2:44 ` Shaopeng He 2015-11-01 15:15 ` [dpdk-dev] [PATCH v4 0/4] fm10k: add " Thomas Monjalon 4 siblings, 0 replies; 27+ messages in thread From: Shaopeng He @ 2015-10-31 2:44 UTC (permalink / raw) To: dev Signed-off-by: Shaopeng He <shaopeng.he@intel.com> Acked-by: Jingjing Wu <jingjing.wu@intel.com> Acked-by: Michael Qiu <michael.qiu@intel.com> --- doc/guides/rel_notes/release_2_2.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/guides/rel_notes/release_2_2.rst b/doc/guides/rel_notes/release_2_2.rst index 116162e..c00344b 100644 --- a/doc/guides/rel_notes/release_2_2.rst +++ b/doc/guides/rel_notes/release_2_2.rst @@ -45,6 +45,11 @@ New Features * **Added port hotplug support to xenvirt.** +* **Added fm10k VMDQ support.** + + Added functions to configure VMDQ mode and add MAC address for each VMDQ + queue pool. Also included logic to do sanity check for multi-queue settings. + Resolved Issues --------------- -- 1.9.3 ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v4 0/4] fm10k: add VMDQ support 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He ` (3 preceding siblings ...) 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 4/4] doc: update release note for fm10k VMDQ support Shaopeng He @ 2015-11-01 15:15 ` Thomas Monjalon 4 siblings, 0 replies; 27+ messages in thread From: Thomas Monjalon @ 2015-11-01 15:15 UTC (permalink / raw) To: Shaopeng He; +Cc: dev 2015-10-31 10:44, Shaopeng He: > This patch series adds VMDQ support for fm10k. > It includes the functions to configure VMDQ mode and > add MAC address for each VMDQ queue pool. > It also includes logic to do sanity check for > multi-queue settings. Applied, thanks ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2015-11-01 15:17 UTC | newest] Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-09-30 7:28 [dpdk-dev] [PATCH 0/3] fm10k: add VMDQ support Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking Shaopeng He 2015-10-15 6:27 ` Qiu, Michael 2015-10-15 11:07 ` He, Shaopeng 2015-10-22 1:23 ` Qiu, Michael 2015-09-30 7:28 ` [dpdk-dev] [PATCH 2/3] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He 2015-09-30 7:28 ` [dpdk-dev] [PATCH 3/3] fm10k: add VMDQ support in multi-queue configure Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 0/4] fm10k: add VMDQ support Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He 2015-10-10 3:22 ` [dpdk-dev] [PATCH v2 4/4] doc: update release note for fm10k VMDQ support Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He 2015-10-30 16:17 ` Thomas Monjalon 2015-10-31 2:22 ` He, Shaopeng 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He 2015-10-27 9:21 ` [dpdk-dev] [PATCH v3 4/4] doc: update release note for fm10k VMDQ support Shaopeng He 2015-10-30 4:42 ` [dpdk-dev] [PATCH v3 0/4] fm10k: add " Wu, Jingjing 2015-10-30 14:07 ` Qiu, Michael 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 " Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 1/4] fm10k: add multi-queue checking Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 2/4] fm10k: add VMDQ support in MAC/VLAN filter Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 3/4] fm10k: add VMDQ support in multi-queue configure Shaopeng He 2015-10-31 2:44 ` [dpdk-dev] [PATCH v4 4/4] doc: update release note for fm10k VMDQ support Shaopeng He 2015-11-01 15:15 ` [dpdk-dev] [PATCH v4 0/4] fm10k: add " Thomas Monjalon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).