Skip to contentSkip to conversation

fm10k: add VMDQ support

PATCH Superseded Shaopeng He 4 participants 27 messages Sep 30, 2015 – Nov 1, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

cover fm10k: add VMDQ support

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(-)
Signature · 1 line
1.9.3
#1 lore raw

PATCH 1/3 fm10k: add multi-queue checking

Add multi-queue checking in device configure process. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +44 -0
index a69c990..082937d 100644
@@ -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;
 }
Signature · 1 line
1.9.3
#2 lore raw

Re: [PATCH 1/3] fm10k: add multi-queue checking

Quoted 27 lines · Shaopeng He

Add multi-queue checking in device configure process. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +11 -0
index a69c990..082937d 100644
@@ -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.");

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) · line 306

Quoted 10 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
+		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

Quoted 32 lines
drivers/net/fm10k/fm10k_ethdev.c +23 -0
+
+	/* 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;
 }
#3 lore raw

Re: [PATCH 1/3] fm10k: add multi-queue checking

Hi, Michael

Quoted 52 lines

-----Original Message-----
From: Qiu, Michael
Sent: Thursday, October 15, 2015 2:28 PM
To: He, Shaopeng; [email protected]
Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw,

Quoted 15 lines · Shaopeng He

Add multi-queue checking in device configure process. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44
++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +0 -0
index a69c990..082937d 100644
@@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw,

uint16_t

Quoted 15 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
 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.");

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) · line 306

Quoted 10 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
+		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.

Quoted 2 lines

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

Quoted 33 lines

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum)

Quoted 4 lines
drivers/net/fm10k/fm10k_ethdev.c +4 -0
+
+	/* Check VMDQ queue pool number */
+	if (vmdq_conf->nb_queue_pools >
+			sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT

||

Quoted 11 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
+			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)  {

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum)

Quoted 10 lines
drivers/net/fm10k/fm10k_ethdev.c +6 -0
+	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.",

Quoted 6 lines
drivers/net/fm10k/fm10k_ethdev.c +3 -0
+			    ret);
+		return ret;
+	}
 
 	return 0;
 }
#4 lore raw

Re: [PATCH 1/3] fm10k: add multi-queue checking

Quoted 53 lines · Shaopeng

Hi, Michael

Quoted 51 lines

-----Original Message-----
From: Qiu, Michael
Sent: Thursday, October 15, 2015 2:28 PM
To: He, Shaopeng; [email protected]
Subject: Re: [dpdk-dev] [PATCH 1/3] fm10k: add multi-queue checking

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw,

Quoted 15 lines · Shaopeng He

Add multi-queue checking in device configure process. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44
++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +0 -0
index a69c990..082937d 100644
@@ -283,12 +283,56 @@ tx_queue_disable(struct fm10k_hw *hw,

uint16_t

Quoted 15 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
 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.");

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum) · line 306

Quoted 10 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
+		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.

Quoted 4 lines
Quoted 2 lines

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

Quoted 36 lines

Thanks,
--Shaopeng

Quoted 33 lines

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum)

Quoted 4 lines
drivers/net/fm10k/fm10k_ethdev.c +4 -0
+
+	/* Check VMDQ queue pool number */
+	if (vmdq_conf->nb_queue_pools >
+			sizeof(vmdq_conf->pool_map[0].pools) * CHAR_BIT

||

Quoted 11 lines
drivers/net/fm10k/fm10k_ethdev.c +10 -0
+			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)  {

drivers/net/fm10k/fm10k_ethdev.c tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum)

Quoted 10 lines
drivers/net/fm10k/fm10k_ethdev.c +6 -0
+	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.",

Quoted 6 lines
drivers/net/fm10k/fm10k_ethdev.c +3 -0
+			    ret);
+		return ret;
+	}
 
 	return 0;
 }
#5 lore raw

PATCH 2/3 fm10k: add VMDQ support in MAC/VLAN filter

In reply to Shaopeng He

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.

---
 drivers/net/fm10k/fm10k.h        |   3 +
 drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++--------------
 2 files changed, 99 insertions(+), 54 deletions(-)
drivers/net/fm10k/fm10k.h +3 -0
index c089882..439e95f 100644
@@ -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 */
 };
 
drivers/net/fm10k/fm10k_ethdev.c +96 -54

213 lines not on this page · raw message

Signature · 1 line
1.9.3
#6 lore raw

PATCH 3/3 fm10k: add VMDQ support in multi-queue configure

In reply to Shaopeng He

Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ configure was changed.

---
 drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------
 1 file changed, 141 insertions(+), 23 deletions(-)
drivers/net/fm10k/fm10k_ethdev.c +141 -23
index cf48cd5..4d6dd57 100644
@@ -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 |
Signature · 1 line
1.9.3
#7 lore raw

v2 cover fm10k: add VMDQ support

In reply to 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.

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(-)
Signature · 1 line
1.9.3
#8 lore raw

PATCH v2 1/4 fm10k: add multi-queue checking

Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +44 -0
index a69c990..082937d 100644
@@ -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;
 }
Signature · 1 line
1.9.3
#9 lore raw

PATCH v2 2/4 fm10k: add VMDQ support in MAC/VLAN filter

In reply to Shaopeng He

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.

---
 drivers/net/fm10k/fm10k.h        |   3 +
 drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++--------------
 2 files changed, 99 insertions(+), 54 deletions(-)
drivers/net/fm10k/fm10k.h +3 -0
index c089882..439e95f 100644
@@ -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 */
 };
 
drivers/net/fm10k/fm10k_ethdev.c +96 -54

213 lines not on this page · raw message

Signature · 1 line
1.9.3
#10 lore raw

PATCH v2 3/4 fm10k: add VMDQ support in multi-queue configure

In reply to Shaopeng He

Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed.

---
 drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------
 1 file changed, 141 insertions(+), 23 deletions(-)
drivers/net/fm10k/fm10k_ethdev.c +141 -23
index cf48cd5..ed8d6a3 100644
@@ -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 |
Signature · 1 line
1.9.3
#11 lore raw

PATCH v2 4/4 doc: update release note for fm10k VMDQ support

In reply to Shaopeng He
---
 doc/guides/rel_notes/release_2_2.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_2_2.rst +5 -0
index 5687676..278149f 100644
@@ -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
 ---------------
Signature · 1 line
1.9.3
#12 lore raw

v3 cover fm10k: add VMDQ support

In reply to 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.

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(-)
Signature · 1 line
1.9.3
#13 lore raw

PATCH v3 1/4 fm10k: add multi-queue checking

Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +44 -0
index a69c990..082937d 100644
@@ -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;
 }
Signature · 1 line
1.9.3
#14 lore raw

PATCH v3 2/4 fm10k: add VMDQ support in MAC/VLAN filter

In reply to Shaopeng He

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.

---
 drivers/net/fm10k/fm10k.h        |   3 +
 drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++--------------
 2 files changed, 99 insertions(+), 54 deletions(-)
drivers/net/fm10k/fm10k.h +3 -0
index c089882..439e95f 100644
@@ -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 */
 };
 
drivers/net/fm10k/fm10k_ethdev.c +96 -54

213 lines not on this page · raw message

Signature · 1 line
1.9.3
#15 lore raw

Re: [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:

drivers/net/fm10k/fm10k_ethdev.c fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) · line 1167

Quoted 1 line
drivers/net/fm10k/fm10k_ethdev.c +1 -0
+	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]

#16 lore raw

Re: [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter

Hi, Thomas

Quoted 8 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Saturday, October 31, 2015 12:18 AM
To: He, Shaopeng
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 2/4] fm10k: add VMDQ support in MAC/VLAN filter

Quoted 7 lines

Sorry it does not compile with clang.

2015-10-27 17:21, Shaopeng He:

drivers/net/fm10k/fm10k_ethdev.c fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask) · line 1167

Quoted 1 line
drivers/net/fm10k/fm10k_ethdev.c +1 -0
+	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

#17 lore raw

PATCH v3 3/4 fm10k: add VMDQ support in multi-queue configure

In reply to Shaopeng He

Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed.

---
 drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------
 1 file changed, 141 insertions(+), 23 deletions(-)
drivers/net/fm10k/fm10k_ethdev.c +141 -23
index cf48cd5..8c31391 100644
@@ -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 |
Signature · 1 line
1.9.3
#18 lore raw

PATCH v3 4/4 doc: update release note for fm10k VMDQ support

In reply to Shaopeng He
---
 doc/guides/rel_notes/release_2_2.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_2_2.rst +5 -0
index 5687676..278149f 100644
@@ -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
 ---------------
Signature · 1 line
1.9.3
Acked-by on the v3 series
#19 lore raw
In reply to Shaopeng He
Quoted 28 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Shaopeng He
Sent: Tuesday, October 27, 2015 5:22 PM
To: [email protected]
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

Quoted 8 lines
 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 on the v3 series
#20 lore raw
In reply to Shaopeng He
Quoted 21 lines · Shaopeng

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

Quoted 5 lines
 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(-)
#21 lore raw

v4 cover fm10k: add VMDQ support

In reply to 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.

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(-)
Signature · 1 line
1.9.3
#22 lore raw

PATCH v4 1/4 fm10k: add multi-queue checking

Add multi-queue checking in device configure function. Currently, VMDQ and RSS are supported.

---
 drivers/net/fm10k/fm10k_ethdev.c | 44 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/net/fm10k/fm10k_ethdev.c +44 -0
index b104fc2..75d1fa3 100644
@@ -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;
 }
Signature · 1 line
1.9.3
#23 lore raw

PATCH v4 2/4 fm10k: add VMDQ support in MAC/VLAN filter

In reply to Shaopeng He

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.

---
 drivers/net/fm10k/fm10k.h        |   3 +
 drivers/net/fm10k/fm10k_ethdev.c | 150 +++++++++++++++++++++++++--------------
 2 files changed, 99 insertions(+), 54 deletions(-)
drivers/net/fm10k/fm10k.h +3 -0
index c089882..439e95f 100644
@@ -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 */
 };
 
drivers/net/fm10k/fm10k_ethdev.c +96 -54

213 lines not on this page · raw message

Signature · 1 line
1.9.3
#24 lore raw

PATCH v4 3/4 fm10k: add VMDQ support in multi-queue configure

In reply to Shaopeng He

Add separate functions to configure VMDQ and RSS. Update dglort map and logic ports accordingly. Reset MAC/VLAN filter after VMDQ config was changed.

---
 drivers/net/fm10k/fm10k_ethdev.c | 164 +++++++++++++++++++++++++++++++++------
 1 file changed, 141 insertions(+), 23 deletions(-)
drivers/net/fm10k/fm10k_ethdev.c +141 -23
index 76c050a..941dae7 100644
@@ -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 |
Signature · 1 line
1.9.3
#25 lore raw

PATCH v4 4/4 doc: update release note for fm10k VMDQ support

In reply to Shaopeng He
---
 doc/guides/rel_notes/release_2_2.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_2_2.rst +5 -0
index 116162e..c00344b 100644
@@ -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
 ---------------
Signature · 1 line
1.9.3
#26 lore raw
In reply to Shaopeng He

2015-10-31 10:44, Shaopeng He:

Quoted 5 lines

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