* [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features
@ 2015-06-02 2:58 Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
` (3 more replies)
0 siblings, 4 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-02 2:58 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
MAC filter was newly added, VLAN filter was updated to add/delete
one static entry in MAC table for each combination of VLAN and MAC address.
Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on.
Shaopeng He (3):
fm10k: update VLAN filter
fm10k: add MAC filter
fm10k: update VLAN offload features
drivers/net/fm10k/fm10k.h | 24 ++++++
drivers/net/fm10k/fm10k_ethdev.c | 167 ++++++++++++++++++++++++++++++++++++---
2 files changed, 181 insertions(+), 10 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
@ 2015-06-02 2:58 ` Shaopeng He
2015-06-09 2:54 ` Chen, Jing D
2015-06-09 15:51 ` Qiu, Michael
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
` (2 subsequent siblings)
3 siblings, 2 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-02 2:58 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
VLAN filter was updated to add/delete one static entry in MAC table for each
combination of VLAN and MAC address. More sanity checks were added.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
drivers/net/fm10k/fm10k_ethdev.c | 55 +++++++++++++++++++++++++++++++++++++---
2 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index ad7a7d1..3b95b72 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -109,11 +109,31 @@
#define FM10K_VLAN_TAG_SIZE 4
+/* Maximum number of MAC addresses per PF/VF */
+#define FM10K_MAX_MACADDR_NUM 1
+
+#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
+#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
+
+/* vlan_id is a 12 bit number.
+ * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
+ * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
+ * The higher 7 bit val specifies VFTA array index.
+ */
+#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
+#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
+
+struct fm10k_macvlan_filter_info {
+ uint16_t vlan_num; /* Total VLAN number */
+ uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
+};
+
struct fm10k_dev_info {
volatile uint32_t enable;
volatile uint32_t glort;
/* Protect the mailbox to avoid race condition */
rte_spinlock_t mbx_lock;
+ struct fm10k_macvlan_filter_info macvlan;
};
/*
@@ -137,6 +157,9 @@ struct fm10k_adapter {
#define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
(&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
+#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
+ (&(((struct fm10k_adapter *)adapter)->info.macvlan))
+
struct fm10k_rx_queue {
struct rte_mempool *mp;
struct rte_mbuf **sw_ring;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 3a26480..d2f3e44 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
- struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ s32 result;
+ uint32_t vid_idx, vid_bit, mac_index;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+ struct rte_eth_dev_data *data = dev->data;
- PMD_INIT_FUNC_TRACE();
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
/* @todo - add support for the VF */
if (hw->mac.type != fm10k_mac_pf)
return -ENOTSUP;
- return fm10k_update_vlan(hw, vlan_id, 0, on);
+ if (vlan_id > ETH_VLAN_ID_MAX) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
+ return (-EINVAL);
+ }
+
+ vid_idx = FM10K_VFTA_IDX(vlan_id);
+ vid_bit = FM10K_VFTA_BIT(vlan_id);
+ /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
+ if (on && (macvlan->vfta[vid_idx] & vid_bit))
+ return 0;
+ /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
+ if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
+ "in the VLAN filter table");
+ return (-EINVAL);
+ }
+
+ fm10k_mbx_lock(hw);
+ result = fm10k_update_vlan(hw, vlan_id, 0, on);
+ if (FM10K_SUCCESS == result) {
+ if (on) {
+ macvlan->vlan_num++;
+ macvlan->vfta[vid_idx] |= vid_bit;
+ } else {
+ macvlan->vlan_num--;
+ macvlan->vfta[vid_idx] &= ~vid_bit;
+ }
+
+ for (mac_index = 0; mac_index < FM10K_MAX_MACADDR_NUM;
+ mac_index++) {
+ if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
+ continue;
+ fm10k_update_uc_addr(hw, hw->mac.dglort_map,
+ data->mac_addrs[mac_index].addr_bytes,
+ vlan_id, on, 0);
+ }
+ }
+ fm10k_mbx_unlock(hw);
+ if (FM10K_SUCCESS == result)
+ return 0;
+ else
+ return (-EIO);
}
static inline int
@@ -1701,6 +1747,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
{
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
int diag;
+ struct fm10k_macvlan_filter_info *macvlan;
PMD_INIT_FUNC_TRACE();
@@ -1715,6 +1762,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+ memset(macvlan, 0, sizeof(*macvlan));
/* Vendor and Device ID need to be set before init of shared code */
memset(hw, 0, sizeof(*hw));
hw->device_id = dev->pci_dev->id.device_id;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
@ 2015-06-02 2:58 ` Shaopeng He
2015-06-09 3:25 ` Chen, Jing D
2015-06-09 15:59 ` Qiu, Michael
2015-06-02 2:58 ` [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
3 siblings, 2 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-02 2:58 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
MAC filter function was newly added, each PF and VF can have up to 64 MAC
addresses. VF filter needs support from PF host, which is not available now.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 3 +-
drivers/net/fm10k/fm10k_ethdev.c | 90 ++++++++++++++++++++++++++++++++++++----
2 files changed, 85 insertions(+), 8 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 3b95b72..f5be5f8 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -110,7 +110,7 @@
#define FM10K_VLAN_TAG_SIZE 4
/* Maximum number of MAC addresses per PF/VF */
-#define FM10K_MAX_MACADDR_NUM 1
+#define FM10K_MAX_MACADDR_NUM 64
#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
@@ -125,6 +125,7 @@
struct fm10k_macvlan_filter_info {
uint16_t vlan_num; /* Total VLAN number */
+ uint16_t mac_num; /* Total mac number */
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 d2f3e44..4f23bf1 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -54,6 +54,10 @@
#define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
static void fm10k_close_mbx_service(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_mbx_initlock(struct fm10k_hw *hw)
@@ -668,14 +672,11 @@ fm10k_dev_start(struct rte_eth_dev *dev)
}
if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) {
- fm10k_mbx_lock(hw);
/* Update default vlan */
- hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);
+ fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
/* Add default mac/vlan filter to PF/Switch manger */
- hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,
- hw->mac.default_vid, true, 0);
- fm10k_mbx_unlock(hw);
+ fm10k_MAC_filter_set(dev, hw->mac.addr, true);
}
return 0;
@@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
dev_info->max_rx_queues = hw->mac.max_queues;
dev_info->max_tx_queues = hw->mac.max_queues;
- dev_info->max_mac_addrs = 1;
+ dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
dev_info->max_hash_mac_addrs = 0;
dev_info->max_vfs = FM10K_MAX_VF_NUM;
dev_info->max_vmdq_pools = ETH_64_POOLS;
@@ -820,6 +821,7 @@ static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
s32 result;
+ uint16_t mac_num = 0;
uint32_t vid_idx, vid_bit, mac_index;
struct fm10k_hw *hw;
struct fm10k_macvlan_filter_info *macvlan;
@@ -864,9 +866,15 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
mac_index++) {
if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
continue;
+ if (mac_num > macvlan->mac_num - 1) {
+ PMD_INIT_LOG(ERR, "MAC address number "
+ "not match");
+ break;
+ }
fm10k_update_uc_addr(hw, hw->mac.dglort_map,
data->mac_addrs[mac_index].addr_bytes,
vlan_id, on, 0);
+ mac_num++;
}
}
fm10k_mbx_unlock(hw);
@@ -876,6 +884,71 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return (-EIO);
}
+/* 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 i, j, k;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+
+ /* @todo - add support for the VF */
+ if (hw->mac.type != fm10k_mac_pf)
+ return;
+
+ fm10k_mbx_lock(hw);
+ 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");
+ fm10k_mbx_unlock(hw);
+ return;
+ }
+ fm10k_update_uc_addr(hw,
+ hw->mac.dglort_map, mac,
+ j * FM10K_UINT32_BIT_SIZE + k,
+ add, 0);
+ i++;
+ }
+ }
+ }
+ }
+ fm10k_mbx_unlock(hw);
+
+ if (add)
+ macvlan->mac_num++;
+ else
+ macvlan->mac_num--;
+}
+
+/* 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)
+{
+ fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
+}
+
+/* Remove a MAC address, and update filters */
+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);
+}
+
static inline int
check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
{
@@ -1728,6 +1801,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .mac_addr_add = fm10k_macaddr_add,
+ .mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
.rx_queue_stop = fm10k_dev_rx_queue_stop,
.tx_queue_start = fm10k_dev_tx_queue_start,
@@ -1809,7 +1884,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
}
/* Initialize MAC address(es) */
- dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
+ dev->data->mac_addrs = rte_zmalloc("fm10k",
+ ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
if (dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
return -ENOMEM;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
@ 2015-06-02 2:58 ` Shaopeng He
2015-06-09 3:27 ` Chen, Jing D
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
3 siblings, 1 reply; 27+ messages in thread
From: Shaopeng He @ 2015-06-02 2:58 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
for PF/VF ports.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k_ethdev.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 4f23bf1..9b198a7 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -884,6 +884,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return (-EIO);
}
+static void
+fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask)
+{
+ if (mask & ETH_VLAN_STRIP_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
+ PMD_INIT_LOG(ERR, "VLAN stripping is "
+ "always on in fm10k");
+ }
+
+ if (mask & ETH_VLAN_EXTEND_MASK) {
+ if (dev->data->dev_conf.rxmode.hw_vlan_extend)
+ PMD_INIT_LOG(ERR, "VLAN QinQ is not "
+ "supported in fm10k");
+ }
+
+ if (mask & ETH_VLAN_FILTER_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
+ PMD_INIT_LOG(ERR, "VLAN filter is always on in fm10k");
+ }
+}
+
/* Add/Remove a MAC address, and update filters */
static void
fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)
@@ -1801,6 +1822,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .vlan_offload_set = fm10k_vlan_offload_set,
.mac_addr_add = fm10k_macaddr_add,
.mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
@ 2015-06-09 2:54 ` Chen, Jing D
2015-06-09 7:18 ` He, Shaopeng
2015-06-09 15:51 ` Qiu, Michael
1 sibling, 1 reply; 27+ messages in thread
From: Chen, Jing D @ 2015-06-09 2:54 UTC (permalink / raw)
To: He, Shaopeng, dev
Hi,
> -----Original Message-----
> From: He, Shaopeng
> Sent: Tuesday, June 02, 2015 10:59 AM
> To: dev@dpdk.org
> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> Subject: [PATCH 1/3] fm10k: update VLAN filter
>
> VLAN filter was updated to add/delete one static entry in MAC table for each
> combination of VLAN and MAC address. More sanity checks were added.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> ---
> drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
> drivers/net/fm10k/fm10k_ethdev.c | 55
> +++++++++++++++++++++++++++++++++++++---
> 2 files changed, 75 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> index ad7a7d1..3b95b72 100644
> --- a/drivers/net/fm10k/fm10k.h
> +++ b/drivers/net/fm10k/fm10k.h
> @@ -109,11 +109,31 @@
>
> #define FM10K_VLAN_TAG_SIZE 4
>
> +/* Maximum number of MAC addresses per PF/VF */
> +#define FM10K_MAX_MACADDR_NUM 1
> +
> +#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> +#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> +
> +/* vlan_id is a 12 bit number.
> + * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> + * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
> + * The higher 7 bit val specifies VFTA array index.
> + */
> +#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
> +#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
> +
> +struct fm10k_macvlan_filter_info {
> + uint16_t vlan_num; /* Total VLAN number */
> + uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> +};
> +
> struct fm10k_dev_info {
> volatile uint32_t enable;
> volatile uint32_t glort;
> /* Protect the mailbox to avoid race condition */
> rte_spinlock_t mbx_lock;
> + struct fm10k_macvlan_filter_info macvlan;
> };
>
> /*
> @@ -137,6 +157,9 @@ struct fm10k_adapter {
> #define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
> (&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
>
> +#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
> + (&(((struct fm10k_adapter *)adapter)->info.macvlan))
> +
> struct fm10k_rx_queue {
> struct rte_mempool *mp;
> struct rte_mbuf **sw_ring;
> diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> b/drivers/net/fm10k/fm10k_ethdev.c
> index 3a26480..d2f3e44 100644
> --- a/drivers/net/fm10k/fm10k_ethdev.c
> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> @@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> static int
> fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> {
> - struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> + s32 result;
> + uint32_t vid_idx, vid_bit, mac_index;
> + struct fm10k_hw *hw;
> + struct fm10k_macvlan_filter_info *macvlan;
> + struct rte_eth_dev_data *data = dev->data;
>
> - PMD_INIT_FUNC_TRACE();
> + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> >dev_private);
>
> /* @todo - add support for the VF */
> if (hw->mac.type != fm10k_mac_pf)
> return -ENOTSUP;
>
> - return fm10k_update_vlan(hw, vlan_id, 0, on);
> + if (vlan_id > ETH_VLAN_ID_MAX) {
> + PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
> + return (-EINVAL);
> + }
> +
> + vid_idx = FM10K_VFTA_IDX(vlan_id);
> + vid_bit = FM10K_VFTA_BIT(vlan_id);
> + /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
> + if (on && (macvlan->vfta[vid_idx] & vid_bit))
> + return 0;
> + /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
> + if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
> + PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
> + "in the VLAN filter table");
> + return (-EINVAL);
> + }
> +
> + fm10k_mbx_lock(hw);
> + result = fm10k_update_vlan(hw, vlan_id, 0, on);
> + if (FM10K_SUCCESS == result) {
> + if (on) {
> + macvlan->vlan_num++;
> + macvlan->vfta[vid_idx] |= vid_bit;
> + } else {
> + macvlan->vlan_num--;
> + macvlan->vfta[vid_idx] &= ~vid_bit;
> + }
> +
> + for (mac_index = 0; mac_index <
> FM10K_MAX_MACADDR_NUM;
> + mac_index++) {
> + if (is_zero_ether_addr(&data-
> >mac_addrs[mac_index]))
> + continue;
> + fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> + data->mac_addrs[mac_index].addr_bytes,
> + vlan_id, on, 0);
Result = fm10k_update_uc_addr()? If meeting any error, it should break.
In the meanwhile, I think above if (on)...else... should be moved after the
loop.
> + }
> + }
> + fm10k_mbx_unlock(hw);
> + if (FM10K_SUCCESS == result)
> + return 0;
> + else
> + return (-EIO);
> }
>
> static inline int
> @@ -1701,6 +1747,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> {
> struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> int diag;
> + struct fm10k_macvlan_filter_info *macvlan;
>
> PMD_INIT_FUNC_TRACE();
>
> @@ -1715,6 +1762,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> return 0;
>
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> >dev_private);
> + memset(macvlan, 0, sizeof(*macvlan));
> /* Vendor and Device ID need to be set before init of shared code */
> memset(hw, 0, sizeof(*hw));
> hw->device_id = dev->pci_dev->id.device_id;
> --
> 1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
@ 2015-06-09 3:25 ` Chen, Jing D
2015-06-09 8:31 ` He, Shaopeng
2015-06-09 15:59 ` Qiu, Michael
1 sibling, 1 reply; 27+ messages in thread
From: Chen, Jing D @ 2015-06-09 3:25 UTC (permalink / raw)
To: He, Shaopeng, dev
Hi,
> -----Original Message-----
> From: He, Shaopeng
> Sent: Tuesday, June 02, 2015 10:59 AM
> To: dev@dpdk.org
> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> Subject: [PATCH 2/3] fm10k: add MAC filter
>
> MAC filter function was newly added, each PF and VF can have up to 64 MAC
> addresses. VF filter needs support from PF host, which is not available now.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> ---
> drivers/net/fm10k/fm10k.h | 3 +-
> drivers/net/fm10k/fm10k_ethdev.c | 90
> ++++++++++++++++++++++++++++++++++++----
> 2 files changed, 85 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> index 3b95b72..f5be5f8 100644
> --- a/drivers/net/fm10k/fm10k.h
> +++ b/drivers/net/fm10k/fm10k.h
> @@ -110,7 +110,7 @@
> #define FM10K_VLAN_TAG_SIZE 4
>
> /* Maximum number of MAC addresses per PF/VF */
> -#define FM10K_MAX_MACADDR_NUM 1
> +#define FM10K_MAX_MACADDR_NUM 64
>
> #define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> #define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> @@ -125,6 +125,7 @@
>
> struct fm10k_macvlan_filter_info {
> uint16_t vlan_num; /* Total VLAN number */
> + uint16_t mac_num; /* Total mac number */
> 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 d2f3e44..4f23bf1 100644
> --- a/drivers/net/fm10k/fm10k_ethdev.c
> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> @@ -54,6 +54,10 @@
> #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
>
> static void fm10k_close_mbx_service(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_mbx_initlock(struct fm10k_hw *hw)
> @@ -668,14 +672,11 @@ fm10k_dev_start(struct rte_eth_dev *dev)
> }
>
> if (hw->mac.default_vid && hw->mac.default_vid <=
> ETHER_MAX_VLAN_ID) {
> - fm10k_mbx_lock(hw);
> /* Update default vlan */
> - hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0,
> true);
> + fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
>
> /* Add default mac/vlan filter to PF/Switch manger */
> - hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map,
> hw->mac.addr,
> - hw->mac.default_vid, true, 0);
> - fm10k_mbx_unlock(hw);
> + fm10k_MAC_filter_set(dev, hw->mac.addr, true);
> }
>
> return 0;
> @@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
> dev_info->max_rx_queues = hw->mac.max_queues;
> dev_info->max_tx_queues = hw->mac.max_queues;
> - dev_info->max_mac_addrs = 1;
> + dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
> dev_info->max_hash_mac_addrs = 0;
> dev_info->max_vfs = FM10K_MAX_VF_NUM;
> dev_info->max_vmdq_pools = ETH_64_POOLS;
> @@ -820,6 +821,7 @@ static int
> fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> {
> s32 result;
> + uint16_t mac_num = 0;
> uint32_t vid_idx, vid_bit, mac_index;
> struct fm10k_hw *hw;
> struct fm10k_macvlan_filter_info *macvlan;
> @@ -864,9 +866,15 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> uint16_t vlan_id, int on)
> mac_index++) {
> if (is_zero_ether_addr(&data-
> >mac_addrs[mac_index]))
> continue;
> + if (mac_num > macvlan->mac_num - 1) {
> + PMD_INIT_LOG(ERR, "MAC address number
> "
> + "not match");
> + break;
> + }
> fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> data->mac_addrs[mac_index].addr_bytes,
> vlan_id, on, 0);
> + mac_num++;
> }
> }
> fm10k_mbx_unlock(hw);
> @@ -876,6 +884,71 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> uint16_t vlan_id, int on)
> return (-EIO);
> }
>
> +/* 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 i, j, k;
> + struct fm10k_hw *hw;
> + struct fm10k_macvlan_filter_info *macvlan;
> +
> + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> >dev_private);
> +
> + /* @todo - add support for the VF */
> + if (hw->mac.type != fm10k_mac_pf)
> + return;
> +
Since it only supports PF, it's better to clarify in the log.
> + fm10k_mbx_lock(hw);
> + 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");
> + fm10k_mbx_unlock(hw);
> + return;
> + }
> + fm10k_update_uc_addr(hw,
> + hw->mac.dglort_map, mac,
> + j * FM10K_UINT32_BIT_SIZE
> + k,
> + add, 0);
> + i++;
> + }
> + }
> + }
> + }
> + fm10k_mbx_unlock(hw);
> +
> + if (add)
> + macvlan->mac_num++;
> + else
> + macvlan->mac_num--;
> +}
> +
> +/* 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)
> +{
> + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
> +}
> +
> +/* Remove a MAC address, and update filters */
> +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);
> +}
> +
> static inline int
> check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
> {
> @@ -1728,6 +1801,8 @@ static const struct eth_dev_ops
> fm10k_eth_dev_ops = {
> .link_update = fm10k_link_update,
> .dev_infos_get = fm10k_dev_infos_get,
> .vlan_filter_set = fm10k_vlan_filter_set,
> + .mac_addr_add = fm10k_macaddr_add,
> + .mac_addr_remove = fm10k_macaddr_remove,
> .rx_queue_start = fm10k_dev_rx_queue_start,
> .rx_queue_stop = fm10k_dev_rx_queue_stop,
> .tx_queue_start = fm10k_dev_tx_queue_start,
> @@ -1809,7 +1884,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> }
>
> /* Initialize MAC address(es) */
> - dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
> + dev->data->mac_addrs = rte_zmalloc("fm10k",
> + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM,
> 0);
> if (dev->data->mac_addrs == NULL) {
> PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC
> addresses");
> return -ENOMEM;
> --
> 1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features
2015-06-02 2:58 ` [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
@ 2015-06-09 3:27 ` Chen, Jing D
2015-06-09 8:55 ` He, Shaopeng
2015-06-09 15:40 ` Qiu, Michael
0 siblings, 2 replies; 27+ messages in thread
From: Chen, Jing D @ 2015-06-09 3:27 UTC (permalink / raw)
To: He, Shaopeng, dev
Hi,
> -----Original Message-----
> From: He, Shaopeng
> Sent: Tuesday, June 02, 2015 10:59 AM
> To: dev@dpdk.org
> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> Subject: [PATCH 3/3] fm10k: update VLAN offload features
>
> Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
> for PF/VF ports.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> ---
> drivers/net/fm10k/fm10k_ethdev.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> b/drivers/net/fm10k/fm10k_ethdev.c
> index 4f23bf1..9b198a7 100644
> --- a/drivers/net/fm10k/fm10k_ethdev.c
> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> @@ -884,6 +884,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> uint16_t vlan_id, int on)
> return (-EIO);
> }
>
> +static void
> +fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask)
> +{
> + if (mask & ETH_VLAN_STRIP_MASK) {
> + if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
> + PMD_INIT_LOG(ERR, "VLAN stripping is "
> + "always on in fm10k");
> + }
> +
> + if (mask & ETH_VLAN_EXTEND_MASK) {
> + if (dev->data->dev_conf.rxmode.hw_vlan_extend)
> + PMD_INIT_LOG(ERR, "VLAN QinQ is not "
> + "supported in fm10k");
> + }
> +
> + if (mask & ETH_VLAN_FILTER_MASK) {
> + if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
> + PMD_INIT_LOG(ERR, "VLAN filter is always on in
> fm10k");
> + }
> +}
> +
Update fm10k_dev_infos_get() to configure above options to expected values?
> /* Add/Remove a MAC address, and update filters */
> static void
> fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)
> @@ -1801,6 +1822,7 @@ static const struct eth_dev_ops
> fm10k_eth_dev_ops = {
> .link_update = fm10k_link_update,
> .dev_infos_get = fm10k_dev_infos_get,
> .vlan_filter_set = fm10k_vlan_filter_set,
> + .vlan_offload_set = fm10k_vlan_offload_set,
> .mac_addr_add = fm10k_macaddr_add,
> .mac_addr_remove = fm10k_macaddr_remove,
> .rx_queue_start = fm10k_dev_rx_queue_start,
> --
> 1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
2015-06-09 2:54 ` Chen, Jing D
@ 2015-06-09 7:18 ` He, Shaopeng
0 siblings, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-09 7:18 UTC (permalink / raw)
To: Chen, Jing D, dev
> -----Original Message-----
> From: Chen, Jing D
> Sent: Tuesday, June 09, 2015 10:54 AM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Qiu, Michael
> Subject: RE: [PATCH 1/3] fm10k: update VLAN filter
>
> Hi,
>
> > -----Original Message-----
> > From: He, Shaopeng
> > Sent: Tuesday, June 02, 2015 10:59 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> > Subject: [PATCH 1/3] fm10k: update VLAN filter
> >
> > VLAN filter was updated to add/delete one static entry in MAC table
> > for each combination of VLAN and MAC address. More sanity checks were
> added.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
> > drivers/net/fm10k/fm10k_ethdev.c | 55
> > +++++++++++++++++++++++++++++++++++++---
> > 2 files changed, 75 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index ad7a7d1..3b95b72 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -109,11 +109,31 @@
> >
> > #define FM10K_VLAN_TAG_SIZE 4
> >
> > +/* Maximum number of MAC addresses per PF/VF */
> > +#define FM10K_MAX_MACADDR_NUM 1
> > +
> > +#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> > +#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> > +
> > +/* vlan_id is a 12 bit number.
> > + * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> > + * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
> > + * The higher 7 bit val specifies VFTA array index.
> > + */
> > +#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
> > +#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
> > +
> > +struct fm10k_macvlan_filter_info {
> > + uint16_t vlan_num; /* Total VLAN number */
> > + uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> > +};
> > +
> > struct fm10k_dev_info {
> > volatile uint32_t enable;
> > volatile uint32_t glort;
> > /* Protect the mailbox to avoid race condition */
> > rte_spinlock_t mbx_lock;
> > + struct fm10k_macvlan_filter_info macvlan;
> > };
> >
> > /*
> > @@ -137,6 +157,9 @@ struct fm10k_adapter { #define
> > FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
> > (&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
> >
> > +#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
> > + (&(((struct fm10k_adapter *)adapter)->info.macvlan))
> > +
> > struct fm10k_rx_queue {
> > struct rte_mempool *mp;
> > struct rte_mbuf **sw_ring;
> > diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> > b/drivers/net/fm10k/fm10k_ethdev.c
> > index 3a26480..d2f3e44 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> > static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t
> > vlan_id, int on) {
> > - struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data-
> > >dev_private);
> > + s32 result;
> > + uint32_t vid_idx, vid_bit, mac_index;
> > + struct fm10k_hw *hw;
> > + struct fm10k_macvlan_filter_info *macvlan;
> > + struct rte_eth_dev_data *data = dev->data;
> >
> > - PMD_INIT_FUNC_TRACE();
> > + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> > >dev_private);
> >
> > /* @todo - add support for the VF */
> > if (hw->mac.type != fm10k_mac_pf)
> > return -ENOTSUP;
> >
> > - return fm10k_update_vlan(hw, vlan_id, 0, on);
> > + if (vlan_id > ETH_VLAN_ID_MAX) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
> > + return (-EINVAL);
> > + }
> > +
> > + vid_idx = FM10K_VFTA_IDX(vlan_id);
> > + vid_bit = FM10K_VFTA_BIT(vlan_id);
> > + /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
> > + if (on && (macvlan->vfta[vid_idx] & vid_bit))
> > + return 0;
> > + /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
> > + if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
> > + "in the VLAN filter table");
> > + return (-EINVAL);
> > + }
> > +
> > + fm10k_mbx_lock(hw);
> > + result = fm10k_update_vlan(hw, vlan_id, 0, on);
> > + if (FM10K_SUCCESS == result) {
> > + if (on) {
> > + macvlan->vlan_num++;
> > + macvlan->vfta[vid_idx] |= vid_bit;
> > + } else {
> > + macvlan->vlan_num--;
> > + macvlan->vfta[vid_idx] &= ~vid_bit;
> > + }
> > +
> > + for (mac_index = 0; mac_index <
> > FM10K_MAX_MACADDR_NUM;
> > + mac_index++) {
> > + if (is_zero_ether_addr(&data-
> > >mac_addrs[mac_index]))
> > + continue;
> > + fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> > + data->mac_addrs[mac_index].addr_bytes,
> > + vlan_id, on, 0);
>
>
> Result = fm10k_update_uc_addr()? If meeting any error, it should break.
> In the meanwhile, I think above if (on)...else... should be moved after the
> loop.
Agree, make sense, thanks for the comment.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter
2015-06-09 3:25 ` Chen, Jing D
@ 2015-06-09 8:31 ` He, Shaopeng
0 siblings, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-09 8:31 UTC (permalink / raw)
To: Chen, Jing D, dev
> -----Original Message-----
> From: Chen, Jing D
> Sent: Tuesday, June 09, 2015 11:25 AM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Qiu, Michael
> Subject: RE: [PATCH 2/3] fm10k: add MAC filter
>
> Hi,
>
> > -----Original Message-----
> > From: He, Shaopeng
> > Sent: Tuesday, June 02, 2015 10:59 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> > Subject: [PATCH 2/3] fm10k: add MAC filter
> >
> > MAC filter function was newly added, each PF and VF can have up to 64
> > MAC addresses. VF filter needs support from PF host, which is not available
> now.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 3 +-
> > drivers/net/fm10k/fm10k_ethdev.c | 90
> > ++++++++++++++++++++++++++++++++++++----
> > 2 files changed, 85 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index 3b95b72..f5be5f8 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -110,7 +110,7 @@
> > #define FM10K_VLAN_TAG_SIZE 4
> >
> > /* Maximum number of MAC addresses per PF/VF */
> > -#define FM10K_MAX_MACADDR_NUM 1
> > +#define FM10K_MAX_MACADDR_NUM 64
> >
> > #define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> > #define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> > @@ -125,6 +125,7 @@
> >
> > struct fm10k_macvlan_filter_info {
> > uint16_t vlan_num; /* Total VLAN number */
> > + uint16_t mac_num; /* Total mac number */
> > 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 d2f3e44..4f23bf1 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -54,6 +54,10 @@
> > #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
> >
> > static void fm10k_close_mbx_service(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_mbx_initlock(struct fm10k_hw *hw) @@ -668,14 +672,11 @@
> > fm10k_dev_start(struct rte_eth_dev *dev)
> > }
> >
> > if (hw->mac.default_vid && hw->mac.default_vid <=
> > ETHER_MAX_VLAN_ID) {
> > - fm10k_mbx_lock(hw);
> > /* Update default vlan */
> > - hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0,
> > true);
> > + fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
> >
> > /* Add default mac/vlan filter to PF/Switch manger */
> > - hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map,
> > hw->mac.addr,
> > - hw->mac.default_vid, true, 0);
> > - fm10k_mbx_unlock(hw);
> > + fm10k_MAC_filter_set(dev, hw->mac.addr, true);
> > }
> >
> > return 0;
> > @@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> > dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
> > dev_info->max_rx_queues = hw->mac.max_queues;
> > dev_info->max_tx_queues = hw->mac.max_queues;
> > - dev_info->max_mac_addrs = 1;
> > + dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
> > dev_info->max_hash_mac_addrs = 0;
> > dev_info->max_vfs = FM10K_MAX_VF_NUM;
> > dev_info->max_vmdq_pools = ETH_64_POOLS;
> > @@ -820,6 +821,7 @@ static int
> > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int
> > on) {
> > s32 result;
> > + uint16_t mac_num = 0;
> > uint32_t vid_idx, vid_bit, mac_index;
> > struct fm10k_hw *hw;
> > struct fm10k_macvlan_filter_info *macvlan; @@ -864,9 +866,15 @@
> > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int
> > on)
> > mac_index++) {
> > if (is_zero_ether_addr(&data-
> > >mac_addrs[mac_index]))
> > continue;
> > + if (mac_num > macvlan->mac_num - 1) {
> > + PMD_INIT_LOG(ERR, "MAC address number
> > "
> > + "not match");
> > + break;
> > + }
> > fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> > data->mac_addrs[mac_index].addr_bytes,
> > vlan_id, on, 0);
> > + mac_num++;
> > }
> > }
> > fm10k_mbx_unlock(hw);
> > @@ -876,6 +884,71 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> > uint16_t vlan_id, int on)
> > return (-EIO);
> > }
> >
> > +/* 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 i, j, k;
> > + struct fm10k_hw *hw;
> > + struct fm10k_macvlan_filter_info *macvlan;
> > +
> > + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> > >dev_private);
> > +
> > + /* @todo - add support for the VF */
> > + if (hw->mac.type != fm10k_mac_pf)
> > + return;
> > +
>
> Since it only supports PF, it's better to clarify in the log.
Accept, thanks for the comment
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features
2015-06-09 3:27 ` Chen, Jing D
@ 2015-06-09 8:55 ` He, Shaopeng
2015-06-09 15:40 ` Qiu, Michael
1 sibling, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-09 8:55 UTC (permalink / raw)
To: Chen, Jing D, dev
> -----Original Message-----
> From: Chen, Jing D
> Sent: Tuesday, June 09, 2015 11:27 AM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Qiu, Michael
> Subject: RE: [PATCH 3/3] fm10k: update VLAN offload features
>
> Hi,
>
>
> > -----Original Message-----
> > From: He, Shaopeng
> > Sent: Tuesday, June 02, 2015 10:59 AM
> > To: dev@dpdk.org
> > Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> > Subject: [PATCH 3/3] fm10k: update VLAN offload features
> >
> > Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
> > for PF/VF ports.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k_ethdev.c | 22 ++++++++++++++++++++++
> > 1 file changed, 22 insertions(+)
> >
> > diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> > b/drivers/net/fm10k/fm10k_ethdev.c
> > index 4f23bf1..9b198a7 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -884,6 +884,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> > uint16_t vlan_id, int on)
> > return (-EIO);
> > }
> >
> > +static void
> > +fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int
> > +mask) {
> > + if (mask & ETH_VLAN_STRIP_MASK) {
> > + if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
> > + PMD_INIT_LOG(ERR, "VLAN stripping is "
> > + "always on in fm10k");
> > + }
> > +
> > + if (mask & ETH_VLAN_EXTEND_MASK) {
> > + if (dev->data->dev_conf.rxmode.hw_vlan_extend)
> > + PMD_INIT_LOG(ERR, "VLAN QinQ is not "
> > + "supported in fm10k");
> > + }
> > +
> > + if (mask & ETH_VLAN_FILTER_MASK) {
> > + if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
> > + PMD_INIT_LOG(ERR, "VLAN filter is always on in
> > fm10k");
> > + }
> > +}
> > +
>
> Update fm10k_dev_infos_get() to configure above options to expected
> values?
Thank you for the reminder, I will update the value of rx_offload_capa
and tx_offload_capa in fm10k_dev_infos_get() in the next version
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features
2015-06-09 3:27 ` Chen, Jing D
2015-06-09 8:55 ` He, Shaopeng
@ 2015-06-09 15:40 ` Qiu, Michael
2015-06-10 6:03 ` He, Shaopeng
1 sibling, 1 reply; 27+ messages in thread
From: Qiu, Michael @ 2015-06-09 15:40 UTC (permalink / raw)
To: Chen, Jing D, He, Shaopeng, dev
On 2015/6/9 11:27, Chen, Jing D wrote:
> Hi,
>
>
>> -----Original Message-----
>> From: He, Shaopeng
>> Sent: Tuesday, June 02, 2015 10:59 AM
>> To: dev@dpdk.org
>> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
>> Subject: [PATCH 3/3] fm10k: update VLAN offload features
>>
>> Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
>> for PF/VF ports.
>>
>> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
>> ---
>> drivers/net/fm10k/fm10k_ethdev.c | 22 ++++++++++++++++++++++
>> 1 file changed, 22 insertions(+)
>>
>> diff --git a/drivers/net/fm10k/fm10k_ethdev.c
>> b/drivers/net/fm10k/fm10k_ethdev.c
>> index 4f23bf1..9b198a7 100644
>> --- a/drivers/net/fm10k/fm10k_ethdev.c
>> +++ b/drivers/net/fm10k/fm10k_ethdev.c
>> @@ -884,6 +884,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
>> uint16_t vlan_id, int on)
>> return (-EIO);
>> }
>>
>> +static void
>> +fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask)
>> +{
>> + if (mask & ETH_VLAN_STRIP_MASK) {
>> + if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
>> + PMD_INIT_LOG(ERR, "VLAN stripping is "
>> + "always on in fm10k");
>> + }
>> +
>> + if (mask & ETH_VLAN_EXTEND_MASK) {
>> + if (dev->data->dev_conf.rxmode.hw_vlan_extend)
>> + PMD_INIT_LOG(ERR, "VLAN QinQ is not "
>> + "supported in fm10k");
>> + }
>> +
>> + if (mask & ETH_VLAN_FILTER_MASK) {
>> + if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
>> + PMD_INIT_LOG(ERR, "VLAN filter is always on in
>> fm10k");
>> + }
>> +}
>> +
> Update fm10k_dev_infos_get() to configure above options to expected values?
Could it be better to add CRC strip options to expected values by
convenient?
Thanks,
Michael
>> /* Add/Remove a MAC address, and update filters */
>> static void
>> fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)
>> @@ -1801,6 +1822,7 @@ static const struct eth_dev_ops
>> fm10k_eth_dev_ops = {
>> .link_update = fm10k_link_update,
>> .dev_infos_get = fm10k_dev_infos_get,
>> .vlan_filter_set = fm10k_vlan_filter_set,
>> + .vlan_offload_set = fm10k_vlan_offload_set,
>> .mac_addr_add = fm10k_macaddr_add,
>> .mac_addr_remove = fm10k_macaddr_remove,
>> .rx_queue_start = fm10k_dev_rx_queue_start,
>> --
>> 1.9.3
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-09 2:54 ` Chen, Jing D
@ 2015-06-09 15:51 ` Qiu, Michael
2015-06-10 5:52 ` He, Shaopeng
1 sibling, 1 reply; 27+ messages in thread
From: Qiu, Michael @ 2015-06-09 15:51 UTC (permalink / raw)
To: He, Shaopeng, dev
On 2015/6/2 10:59, He, Shaopeng wrote:
> VLAN filter was updated to add/delete one static entry in MAC table for each
> combination of VLAN and MAC address. More sanity checks were added.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> ---
> drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
> drivers/net/fm10k/fm10k_ethdev.c | 55 +++++++++++++++++++++++++++++++++++++---
> 2 files changed, 75 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> index ad7a7d1..3b95b72 100644
> --- a/drivers/net/fm10k/fm10k.h
> +++ b/drivers/net/fm10k/fm10k.h
> @@ -109,11 +109,31 @@
>
> #define FM10K_VLAN_TAG_SIZE 4
>
> +/* Maximum number of MAC addresses per PF/VF */
> +#define FM10K_MAX_MACADDR_NUM 1
> +
> +#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> +#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> +
> +/* vlan_id is a 12 bit number.
> + * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> + * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
> + * The higher 7 bit val specifies VFTA array index.
> + */
> +#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
> +#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
> +
> +struct fm10k_macvlan_filter_info {
> + uint16_t vlan_num; /* Total VLAN number */
> + uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> +};
> +
> struct fm10k_dev_info {
> volatile uint32_t enable;
> volatile uint32_t glort;
> /* Protect the mailbox to avoid race condition */
> rte_spinlock_t mbx_lock;
> + struct fm10k_macvlan_filter_info macvlan;
> };
>
> /*
> @@ -137,6 +157,9 @@ struct fm10k_adapter {
> #define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
> (&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
>
> +#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
> + (&(((struct fm10k_adapter *)adapter)->info.macvlan))
> +
> struct fm10k_rx_queue {
> struct rte_mempool *mp;
> struct rte_mbuf **sw_ring;
> diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
> index 3a26480..d2f3e44 100644
> --- a/drivers/net/fm10k/fm10k_ethdev.c
> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> @@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> static int
> fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> {
> - struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + s32 result;
> + uint32_t vid_idx, vid_bit, mac_index;
> + struct fm10k_hw *hw;
> + struct fm10k_macvlan_filter_info *macvlan;
> + struct rte_eth_dev_data *data = dev->data;
>
> - PMD_INIT_FUNC_TRACE();
> + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
>
> /* @todo - add support for the VF */
> if (hw->mac.type != fm10k_mac_pf)
> return -ENOTSUP;
>
> - return fm10k_update_vlan(hw, vlan_id, 0, on);
> + if (vlan_id > ETH_VLAN_ID_MAX) {
> + PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
> + return (-EINVAL);
> + }
> +
> + vid_idx = FM10K_VFTA_IDX(vlan_id);
> + vid_bit = FM10K_VFTA_BIT(vlan_id);
> + /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
> + if (on && (macvlan->vfta[vid_idx] & vid_bit))
> + return 0;
> + /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
> + if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
> + PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
> + "in the VLAN filter table");
> + return (-EINVAL);
> + }
> +
> + fm10k_mbx_lock(hw);
> + result = fm10k_update_vlan(hw, vlan_id, 0, on);
Would it make sense about release the lock here? So that to make sure we
do not hold this lock for a long time.
> + if (FM10K_SUCCESS == result) {
> + if (on) {
> + macvlan->vlan_num++;
> + macvlan->vfta[vid_idx] |= vid_bit;
> + } else {
> + macvlan->vlan_num--;
> + macvlan->vfta[vid_idx] &= ~vid_bit;
> + }
> +
> + for (mac_index = 0; mac_index < FM10K_MAX_MACADDR_NUM;
> + mac_index++) {
> + if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
> + continue;
> + fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> + data->mac_addrs[mac_index].addr_bytes,
> + vlan_id, on, 0);
> + }
> + }
> + fm10k_mbx_unlock(hw);
> + if (FM10K_SUCCESS == result)
> + return 0;
> + else
> + return (-EIO);
> }
>
> static inline int
> @@ -1701,6 +1747,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> {
> struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> int diag;
> + struct fm10k_macvlan_filter_info *macvlan;
>
> PMD_INIT_FUNC_TRACE();
>
> @@ -1715,6 +1762,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> return 0;
>
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
> + memset(macvlan, 0, sizeof(*macvlan));
> /* Vendor and Device ID need to be set before init of shared code */
> memset(hw, 0, sizeof(*hw));
> hw->device_id = dev->pci_dev->id.device_id;
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
2015-06-09 3:25 ` Chen, Jing D
@ 2015-06-09 15:59 ` Qiu, Michael
2015-06-10 1:03 ` He, Shaopeng
1 sibling, 1 reply; 27+ messages in thread
From: Qiu, Michael @ 2015-06-09 15:59 UTC (permalink / raw)
To: He, Shaopeng, dev
On 2015/6/2 10:59, He, Shaopeng wrote:
> MAC filter function was newly added, each PF and VF can have up to 64 MAC
> addresses. VF filter needs support from PF host, which is not available now.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> ---
> drivers/net/fm10k/fm10k.h | 3 +-
> drivers/net/fm10k/fm10k_ethdev.c | 90 ++++++++++++++++++++++++++++++++++++----
> 2 files changed, 85 insertions(+), 8 deletions(-)
...
> ;
> +
> + fm10k_mbx_lock(hw);
> + 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");
> + fm10k_mbx_unlock(hw);
> + return;
> + }
> + fm10k_update_uc_addr(hw,
> + hw->mac.dglort_map, mac,
Here before 'mac', does it has a incident? if no, please ignore, maybe
my mail client's issue.
Thanks,
Michael
> + j * FM10K_UINT32_BIT_SIZE + k,
> + add, 0);
> + i++;
> + }
> + }
> + }
> + }
> + fm10k_mbx_unlock(hw);
> +
> + if (add)
> + macvlan->mac_num++;
> + else
> + macvlan->mac_num--;
> +}
> +
> +/* 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)
> +{
> + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
> +}
> +
> +/* Remove a MAC address, and update filters */
> +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);
> +}
> +
> static inline int
> check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
> {
> @@ -1728,6 +1801,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
> .link_update = fm10k_link_update,
> .dev_infos_get = fm10k_dev_infos_get,
> .vlan_filter_set = fm10k_vlan_filter_set,
> + .mac_addr_add = fm10k_macaddr_add,
> + .mac_addr_remove = fm10k_macaddr_remove,
> .rx_queue_start = fm10k_dev_rx_queue_start,
> .rx_queue_stop = fm10k_dev_rx_queue_stop,
> .tx_queue_start = fm10k_dev_tx_queue_start,
> @@ -1809,7 +1884,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> }
>
> /* Initialize MAC address(es) */
> - dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
> + dev->data->mac_addrs = rte_zmalloc("fm10k",
> + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
> if (dev->data->mac_addrs == NULL) {
> PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
> return -ENOMEM;
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter
2015-06-09 15:59 ` Qiu, Michael
@ 2015-06-10 1:03 ` He, Shaopeng
0 siblings, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-10 1:03 UTC (permalink / raw)
To: Qiu, Michael, dev
> -----Original Message-----
> From: Qiu, Michael
> Sent: Wednesday, June 10, 2015 12:00 AM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Chen, Jing D
> Subject: Re: [PATCH 2/3] fm10k: add MAC filter
>
> On 2015/6/2 10:59, He, Shaopeng wrote:
> > MAC filter function was newly added, each PF and VF can have up to 64
> > MAC addresses. VF filter needs support from PF host, which is not available
> now.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 3 +-
> > drivers/net/fm10k/fm10k_ethdev.c | 90
> > ++++++++++++++++++++++++++++++++++++----
> > 2 files changed, 85 insertions(+), 8 deletions(-)
>
> ...
>
> > ;
> > +
> > + fm10k_mbx_lock(hw);
> > + 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");
> > + fm10k_mbx_unlock(hw);
> > + return;
> > + }
> > + fm10k_update_uc_addr(hw,
> > + hw->mac.dglort_map, mac,
>
> Here before 'mac', does it has a incident? if no, please ignore, maybe my mail
> client's issue.
>
> Thanks,
> Michael
Thanks for pointing out, will be fixed in next version
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter
2015-06-09 15:51 ` Qiu, Michael
@ 2015-06-10 5:52 ` He, Shaopeng
0 siblings, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-10 5:52 UTC (permalink / raw)
To: Qiu, Michael, dev
> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, June 09, 2015 11:52 PM
> To: He, Shaopeng; dev@dpdk.org
> Cc: Chen, Jing D
> Subject: Re: [PATCH 1/3] fm10k: update VLAN filter
>
> On 2015/6/2 10:59, He, Shaopeng wrote:
> > VLAN filter was updated to add/delete one static entry in MAC table
> > for each combination of VLAN and MAC address. More sanity checks were
> added.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 23 +++++++++++++++++
> > drivers/net/fm10k/fm10k_ethdev.c | 55
> > +++++++++++++++++++++++++++++++++++++---
> > 2 files changed, 75 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index ad7a7d1..3b95b72 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -109,11 +109,31 @@
> >
> > #define FM10K_VLAN_TAG_SIZE 4
> >
> > +/* Maximum number of MAC addresses per PF/VF */
> > +#define FM10K_MAX_MACADDR_NUM 1
> > +
> > +#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> > +#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> > +
> > +/* vlan_id is a 12 bit number.
> > + * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
> > + * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
> > + * The higher 7 bit val specifies VFTA array index.
> > + */
> > +#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
> > +#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
> > +
> > +struct fm10k_macvlan_filter_info {
> > + uint16_t vlan_num; /* Total VLAN number */
> > + uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> > +};
> > +
> > struct fm10k_dev_info {
> > volatile uint32_t enable;
> > volatile uint32_t glort;
> > /* Protect the mailbox to avoid race condition */
> > rte_spinlock_t mbx_lock;
> > + struct fm10k_macvlan_filter_info macvlan;
> > };
> >
> > /*
> > @@ -137,6 +157,9 @@ struct fm10k_adapter { #define
> > FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
> > (&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
> >
> > +#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
> > + (&(((struct fm10k_adapter *)adapter)->info.macvlan))
> > +
> > struct fm10k_rx_queue {
> > struct rte_mempool *mp;
> > struct rte_mbuf **sw_ring;
> > diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> > b/drivers/net/fm10k/fm10k_ethdev.c
> > index 3a26480..d2f3e44 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -819,15 +819,61 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> > static int fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t
> > vlan_id, int on) {
> > - struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data-
> >dev_private);
> > + s32 result;
> > + uint32_t vid_idx, vid_bit, mac_index;
> > + struct fm10k_hw *hw;
> > + struct fm10k_macvlan_filter_info *macvlan;
> > + struct rte_eth_dev_data *data = dev->data;
> >
> > - PMD_INIT_FUNC_TRACE();
> > + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> >dev_private);
> >
> > /* @todo - add support for the VF */
> > if (hw->mac.type != fm10k_mac_pf)
> > return -ENOTSUP;
> >
> > - return fm10k_update_vlan(hw, vlan_id, 0, on);
> > + if (vlan_id > ETH_VLAN_ID_MAX) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
> > + return (-EINVAL);
> > + }
> > +
> > + vid_idx = FM10K_VFTA_IDX(vlan_id);
> > + vid_bit = FM10K_VFTA_BIT(vlan_id);
> > + /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
> > + if (on && (macvlan->vfta[vid_idx] & vid_bit))
> > + return 0;
> > + /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
> > + if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
> > + PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
> > + "in the VLAN filter table");
> > + return (-EINVAL);
> > + }
> > +
> > + fm10k_mbx_lock(hw);
> > + result = fm10k_update_vlan(hw, vlan_id, 0, on);
>
> Would it make sense about release the lock here? So that to make sure we
> do not hold this lock for a long time.
Agree, make sense, thanks for the suggestion!
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features
2015-06-09 15:40 ` Qiu, Michael
@ 2015-06-10 6:03 ` He, Shaopeng
0 siblings, 0 replies; 27+ messages in thread
From: He, Shaopeng @ 2015-06-10 6:03 UTC (permalink / raw)
To: Qiu, Michael, Chen, Jing D, dev
> -----Original Message-----
> From: Qiu, Michael
> Sent: Tuesday, June 09, 2015 11:41 PM
> To: Chen, Jing D; He, Shaopeng; dev@dpdk.org
> Subject: Re: [PATCH 3/3] fm10k: update VLAN offload features
>
> On 2015/6/9 11:27, Chen, Jing D wrote:
> > Hi,
> >
> >
> >> -----Original Message-----
> >> From: He, Shaopeng
> >> Sent: Tuesday, June 02, 2015 10:59 AM
> >> To: dev@dpdk.org
> >> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> >> Subject: [PATCH 3/3] fm10k: update VLAN offload features
> >>
> >> Fm10k PF/VF does not support QinQ; VLAN strip and filter are always
> >> on for PF/VF ports.
> >>
> >> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
> >> ---
> >> drivers/net/fm10k/fm10k_ethdev.c | 22 ++++++++++++++++++++++
> >> 1 file changed, 22 insertions(+)
> >>
> >> diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> >> b/drivers/net/fm10k/fm10k_ethdev.c
> >> index 4f23bf1..9b198a7 100644
> >> --- a/drivers/net/fm10k/fm10k_ethdev.c
> >> +++ b/drivers/net/fm10k/fm10k_ethdev.c
> >> @@ -884,6 +884,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> >> uint16_t vlan_id, int on)
> >> return (-EIO);
> >> }
> >>
> >> +static void
> >> +fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int
> >> +mask) {
> >> + if (mask & ETH_VLAN_STRIP_MASK) {
> >> + if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
> >> + PMD_INIT_LOG(ERR, "VLAN stripping is "
> >> + "always on in fm10k");
> >> + }
> >> +
> >> + if (mask & ETH_VLAN_EXTEND_MASK) {
> >> + if (dev->data->dev_conf.rxmode.hw_vlan_extend)
> >> + PMD_INIT_LOG(ERR, "VLAN QinQ is not "
> >> + "supported in fm10k");
> >> + }
> >> +
> >> + if (mask & ETH_VLAN_FILTER_MASK) {
> >> + if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
> >> + PMD_INIT_LOG(ERR, "VLAN filter is always on in
> >> fm10k");
> >> + }
> >> +}
> >> +
> > Update fm10k_dev_infos_get() to configure above options to expected
> values?
>
> Could it be better to add CRC strip options to expected values by convenient?
Thanks for the comments; but this patch is for the VLAN offload, may not be good
place to fix other bugs. By the way, current struct rte_eth_dev_info
which fm10k_dev_infos_get() returns does not have
any setting for CRC strip options (please correct me if I am wrong).
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and VLAN offload features
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
` (2 preceding siblings ...)
2015-06-02 2:58 ` [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
@ 2015-06-15 1:23 ` Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
` (3 more replies)
3 siblings, 4 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-15 1:23 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
v2 changes:
- add result check when updating MAC address table for VLAN filter
- move VLAN Table updating to the end of VLAN filter process
- release mailbox lock immediately after each mailbox related operation
- update the value of rx_offload_capa and tx_offload_capa
- fix miscelleous review comments
The patch series introduce changes for MAC/VLAN filter and VLAN offload features.
MAC filter is newly added, VLAN filter is updated to add/delete
one static entry in MAC table for each combination of VLAN and MAC address.
For VLAN offload features, Fm10k PF/VF does not support QinQ;
and VLAN strip and filter are always on.
Shaopeng He (3):
fm10k: update VLAN filter
fm10k: add MAC filter
fm10k: update VLAN offload features
drivers/net/fm10k/fm10k.h | 24 ++++++
drivers/net/fm10k/fm10k_ethdev.c | 182 ++++++++++++++++++++++++++++++++++++---
2 files changed, 194 insertions(+), 12 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
@ 2015-06-15 1:23 ` Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
` (2 subsequent siblings)
3 siblings, 0 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-15 1:23 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
VLAN filter was updated to add/delete one static entry in MAC table for each
combination of VLAN and MAC address. More sanity checks were added.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 23 ++++++++++++++
drivers/net/fm10k/fm10k_ethdev.c | 65 +++++++++++++++++++++++++++++++++++++---
2 files changed, 84 insertions(+), 4 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index ad7a7d1..3b95b72 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -109,11 +109,31 @@
#define FM10K_VLAN_TAG_SIZE 4
+/* Maximum number of MAC addresses per PF/VF */
+#define FM10K_MAX_MACADDR_NUM 1
+
+#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
+#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
+
+/* vlan_id is a 12 bit number.
+ * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
+ * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
+ * The higher 7 bit val specifies VFTA array index.
+ */
+#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
+#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
+
+struct fm10k_macvlan_filter_info {
+ uint16_t vlan_num; /* Total VLAN number */
+ uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
+};
+
struct fm10k_dev_info {
volatile uint32_t enable;
volatile uint32_t glort;
/* Protect the mailbox to avoid race condition */
rte_spinlock_t mbx_lock;
+ struct fm10k_macvlan_filter_info macvlan;
};
/*
@@ -137,6 +157,9 @@ struct fm10k_adapter {
#define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
(&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
+#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
+ (&(((struct fm10k_adapter *)adapter)->info.macvlan))
+
struct fm10k_rx_queue {
struct rte_mempool *mp;
struct rte_mbuf **sw_ring;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 3a26480..bc2d67d 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -819,15 +819,69 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
- struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ s32 result;
+ uint32_t vid_idx, vid_bit, mac_index;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+ struct rte_eth_dev_data *data = dev->data;
- PMD_INIT_FUNC_TRACE();
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
/* @todo - add support for the VF */
- if (hw->mac.type != fm10k_mac_pf)
+ if (hw->mac.type != fm10k_mac_pf) {
+ PMD_INIT_LOG(ERR, "VLAN filter not available on VF");
return -ENOTSUP;
+ }
+
+ if (vlan_id > ETH_VLAN_ID_MAX) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
+ return (-EINVAL);
+ }
+
+ vid_idx = FM10K_VFTA_IDX(vlan_id);
+ vid_bit = FM10K_VFTA_BIT(vlan_id);
+ /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
+ if (on && (macvlan->vfta[vid_idx] & vid_bit))
+ return 0;
+ /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
+ if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
+ "in the VLAN filter table");
+ return (-EINVAL);
+ }
- return fm10k_update_vlan(hw, vlan_id, 0, on);
+ fm10k_mbx_lock(hw);
+ result = fm10k_update_vlan(hw, vlan_id, 0, on);
+ fm10k_mbx_unlock(hw);
+ if (result != FM10K_SUCCESS) {
+ PMD_INIT_LOG(ERR, "VLAN update failed: %d", result);
+ return (-EIO);
+ }
+
+ for (mac_index = 0; mac_index < FM10K_MAX_MACADDR_NUM;
+ mac_index++) {
+ if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
+ continue;
+ fm10k_mbx_lock(hw);
+ result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
+ data->mac_addrs[mac_index].addr_bytes,
+ vlan_id, on, 0);
+ fm10k_mbx_unlock(hw);
+ }
+ if (result != FM10K_SUCCESS) {
+ PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
+ return (-EIO);
+ }
+
+ if (on) {
+ macvlan->vlan_num++;
+ macvlan->vfta[vid_idx] |= vid_bit;
+ } else {
+ macvlan->vlan_num--;
+ macvlan->vfta[vid_idx] &= ~vid_bit;
+ }
+ return 0;
}
static inline int
@@ -1701,6 +1755,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
{
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
int diag;
+ struct fm10k_macvlan_filter_info *macvlan;
PMD_INIT_FUNC_TRACE();
@@ -1715,6 +1770,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+ memset(macvlan, 0, sizeof(*macvlan));
/* Vendor and Device ID need to be set before init of shared code */
memset(hw, 0, sizeof(*hw));
hw->device_id = dev->pci_dev->id.device_id;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
@ 2015-06-15 1:23 ` Shaopeng He
2015-06-16 12:38 ` Qiu, Michael
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
3 siblings, 1 reply; 27+ messages in thread
From: Shaopeng He @ 2015-06-15 1:23 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
MAC filter function was newly added, each PF and VF can have up to 64 MAC
addresses. VF filter needs support from PF host, which is not available now.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 3 +-
drivers/net/fm10k/fm10k_ethdev.c | 91 ++++++++++++++++++++++++++++++++++++----
2 files changed, 86 insertions(+), 8 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 3b95b72..f5be5f8 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -110,7 +110,7 @@
#define FM10K_VLAN_TAG_SIZE 4
/* Maximum number of MAC addresses per PF/VF */
-#define FM10K_MAX_MACADDR_NUM 1
+#define FM10K_MAX_MACADDR_NUM 64
#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
@@ -125,6 +125,7 @@
struct fm10k_macvlan_filter_info {
uint16_t vlan_num; /* Total VLAN number */
+ uint16_t mac_num; /* Total mac number */
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 bc2d67d..5f962d2 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -54,6 +54,10 @@
#define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
static void fm10k_close_mbx_service(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_mbx_initlock(struct fm10k_hw *hw)
@@ -668,14 +672,11 @@ fm10k_dev_start(struct rte_eth_dev *dev)
}
if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) {
- fm10k_mbx_lock(hw);
/* Update default vlan */
- hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);
+ fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
/* Add default mac/vlan filter to PF/Switch manger */
- hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,
- hw->mac.default_vid, true, 0);
- fm10k_mbx_unlock(hw);
+ fm10k_MAC_filter_set(dev, hw->mac.addr, true);
}
return 0;
@@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
dev_info->max_rx_queues = hw->mac.max_queues;
dev_info->max_tx_queues = hw->mac.max_queues;
- dev_info->max_mac_addrs = 1;
+ dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
dev_info->max_hash_mac_addrs = 0;
dev_info->max_vfs = FM10K_MAX_VF_NUM;
dev_info->max_vmdq_pools = ETH_64_POOLS;
@@ -820,6 +821,7 @@ static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
s32 result;
+ uint16_t mac_num = 0;
uint32_t vid_idx, vid_bit, mac_index;
struct fm10k_hw *hw;
struct fm10k_macvlan_filter_info *macvlan;
@@ -863,11 +865,17 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
mac_index++) {
if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
continue;
+ if (mac_num > macvlan->mac_num - 1) {
+ PMD_INIT_LOG(ERR, "MAC address number "
+ "not match");
+ break;
+ }
fm10k_mbx_lock(hw);
result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
data->mac_addrs[mac_index].addr_bytes,
vlan_id, on, 0);
fm10k_mbx_unlock(hw);
+ mac_num++;
}
if (result != FM10K_SUCCESS) {
PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
@@ -884,6 +892,72 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return 0;
}
+/* 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 i, j, k;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+
+ /* @todo - add support for the VF */
+ if (hw->mac.type != fm10k_mac_pf) {
+ PMD_INIT_LOG(ERR, "MAC filter not available on VF");
+ return;
+ }
+
+ 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 (add)
+ macvlan->mac_num++;
+ else
+ macvlan->mac_num--;
+}
+
+/* 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)
+{
+ fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
+}
+
+/* Remove a MAC address, and update filters */
+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);
+}
+
static inline int
check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
{
@@ -1736,6 +1810,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .mac_addr_add = fm10k_macaddr_add,
+ .mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
.rx_queue_stop = fm10k_dev_rx_queue_stop,
.tx_queue_start = fm10k_dev_tx_queue_start,
@@ -1817,7 +1893,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
}
/* Initialize MAC address(es) */
- dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
+ dev->data->mac_addrs = rte_zmalloc("fm10k",
+ ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
if (dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
return -ENOMEM;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v2 3/3] fm10k: update VLAN offload features
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
@ 2015-06-15 1:23 ` Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
3 siblings, 0 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-15 1:23 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
for PF/VF ports.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k_ethdev.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 5f962d2..802a930 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -787,10 +787,12 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_vfs = FM10K_MAX_VF_NUM;
dev_info->max_vmdq_pools = ETH_64_POOLS;
dev_info->rx_offload_capa =
+ DEV_RX_OFFLOAD_VLAN_STRIP |
DEV_RX_OFFLOAD_IPV4_CKSUM |
DEV_RX_OFFLOAD_UDP_CKSUM |
DEV_RX_OFFLOAD_TCP_CKSUM;
- dev_info->tx_offload_capa = 0;
+ dev_info->tx_offload_capa =
+ DEV_TX_OFFLOAD_VLAN_INSERT;
dev_info->reta_size = FM10K_MAX_RSS_INDICES;
dev_info->default_rxconf = (struct rte_eth_rxconf) {
@@ -892,6 +894,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return 0;
}
+static void
+fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask)
+{
+ if (mask & ETH_VLAN_STRIP_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
+ PMD_INIT_LOG(ERR, "VLAN stripping is "
+ "always on in fm10k");
+ }
+
+ if (mask & ETH_VLAN_EXTEND_MASK) {
+ if (dev->data->dev_conf.rxmode.hw_vlan_extend)
+ PMD_INIT_LOG(ERR, "VLAN QinQ is not "
+ "supported in fm10k");
+ }
+
+ if (mask & ETH_VLAN_FILTER_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
+ PMD_INIT_LOG(ERR, "VLAN filter is always on in fm10k");
+ }
+}
+
/* Add/Remove a MAC address, and update filters */
static void
fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)
@@ -1810,6 +1833,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .vlan_offload_set = fm10k_vlan_offload_set,
.mac_addr_add = fm10k_macaddr_add,
.mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
@ 2015-06-16 12:38 ` Qiu, Michael
0 siblings, 0 replies; 27+ messages in thread
From: Qiu, Michael @ 2015-06-16 12:38 UTC (permalink / raw)
To: He, Shaopeng, dev
On 6/15/2015 9:25 AM, He, Shaopeng wrote:
> MAC filter function was newly added, each PF and VF can have up to 64 MAC
> addresses. VF filter needs support from PF host, which is not available now.
>
> Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
[.../...]
> @@ -820,6 +821,7 @@ static int
> fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> {
> s32 result;
> + uint16_t mac_num = 0;
> uint32_t vid_idx, vid_bit, mac_index;
> struct fm10k_hw *hw;
> struct fm10k_macvlan_filter_info *macvlan;
> @@ -863,11 +865,17 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> mac_index++) {
> if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
> continue;
> + if (mac_num > macvlan->mac_num - 1) {
> + PMD_INIT_LOG(ERR, "MAC address number "
> + "not match");
It's so strange why so many indentations here.
> + break;
> + }
> fm10k_mbx_lock(hw);
> result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> data->mac_addrs[mac_index].addr_bytes,
> vlan_id, on, 0);
> fm10k_mbx_unlock(hw);
> + mac_num++;
> }
> if (result != FM10K_SUCCESS) {
> PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
> @@ -884,6 +892,72 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
> return 0;
> }
>
> +/* 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 i, j, k;
> + struct fm10k_hw *hw;
> + struct fm10k_macvlan_filter_info *macvlan;
> +
> + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
> +
> + /* @todo - add support for the VF */
> + if (hw->mac.type != fm10k_mac_pf) {
> + PMD_INIT_LOG(ERR, "MAC filter not available on VF");
> + return;
> + }
> +
> + 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 (add)
> + macvlan->mac_num++;
> + else
> + macvlan->mac_num--;
> +}
> +
> +/* 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)
> +{
> + fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
> +}
> +
> +/* Remove a MAC address, and update filters */
> +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);
> +}
> +
> static inline int
> check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
> {
> @@ -1736,6 +1810,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
> .link_update = fm10k_link_update,
> .dev_infos_get = fm10k_dev_infos_get,
> .vlan_filter_set = fm10k_vlan_filter_set,
> + .mac_addr_add = fm10k_macaddr_add,
> + .mac_addr_remove = fm10k_macaddr_remove,
> .rx_queue_start = fm10k_dev_rx_queue_start,
> .rx_queue_stop = fm10k_dev_rx_queue_stop,
> .tx_queue_start = fm10k_dev_tx_queue_start,
> @@ -1817,7 +1893,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
> }
>
> /* Initialize MAC address(es) */
> - dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
> + dev->data->mac_addrs = rte_zmalloc("fm10k",
> + ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
> if (dev->data->mac_addrs == NULL) {
> PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
> return -ENOMEM;
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and VLAN offload features
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
` (2 preceding siblings ...)
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 3/3] fm10k: update VLAN offload features Shaopeng He
@ 2015-06-18 7:21 ` Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
` (3 more replies)
3 siblings, 4 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-18 7:21 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
v3 changes:
- add more result check for MAC table mailbox operation for VLAN filter
- remove two extra indentation tabs
v2 changes:
- add result check when updating MAC address table for VLAN filter
- move VLAN Table updating to the end of VLAN filter process
- release mailbox lock immediately after each mailbox related operation
- update the value of rx_offload_capa and tx_offload_capa
- fix miscelleous review comments
The patch series introduce changes for MAC/VLAN filter and VLAN offload features.
MAC filter is newly added, VLAN filter is updated to add/delete
one static entry in MAC table for each combination of VLAN and MAC address.
For VLAN offload features, Fm10k PF/VF does not support QinQ;
and VLAN strip and filter are always on.
Shaopeng He (3):
fm10k: update VLAN filter
fm10k: add MAC filter
fm10k: update VLAN offload features
drivers/net/fm10k/fm10k.h | 24 ++++++
drivers/net/fm10k/fm10k_ethdev.c | 182 ++++++++++++++++++++++++++++++++++++---
2 files changed, 194 insertions(+), 12 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
@ 2015-06-18 7:21 ` Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 2/3] fm10k: add MAC filter Shaopeng He
` (2 subsequent siblings)
3 siblings, 0 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-18 7:21 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
VLAN filter was updated to add/delete one static entry in MAC table for each
combination of VLAN and MAC address. More sanity checks were added.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 23 ++++++++++++++
drivers/net/fm10k/fm10k_ethdev.c | 65 +++++++++++++++++++++++++++++++++++++---
2 files changed, 84 insertions(+), 4 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index ad7a7d1..3b95b72 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -109,11 +109,31 @@
#define FM10K_VLAN_TAG_SIZE 4
+/* Maximum number of MAC addresses per PF/VF */
+#define FM10K_MAX_MACADDR_NUM 1
+
+#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
+#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
+
+/* vlan_id is a 12 bit number.
+ * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
+ * 2^5 = 32. The val of lower 5 bits specifies the bit in the 32bit element.
+ * The higher 7 bit val specifies VFTA array index.
+ */
+#define FM10K_VFTA_BIT(vlan_id) (1 << ((vlan_id) & 0x1F))
+#define FM10K_VFTA_IDX(vlan_id) ((vlan_id) >> 5)
+
+struct fm10k_macvlan_filter_info {
+ uint16_t vlan_num; /* Total VLAN number */
+ uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
+};
+
struct fm10k_dev_info {
volatile uint32_t enable;
volatile uint32_t glort;
/* Protect the mailbox to avoid race condition */
rte_spinlock_t mbx_lock;
+ struct fm10k_macvlan_filter_info macvlan;
};
/*
@@ -137,6 +157,9 @@ struct fm10k_adapter {
#define FM10K_DEV_PRIVATE_TO_MBXLOCK(adapter) \
(&(((struct fm10k_adapter *)adapter)->info.mbx_lock))
+#define FM10K_DEV_PRIVATE_TO_MACVLAN(adapter) \
+ (&(((struct fm10k_adapter *)adapter)->info.macvlan))
+
struct fm10k_rx_queue {
struct rte_mempool *mp;
struct rte_mbuf **sw_ring;
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 3a26480..b55a5a7 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -819,15 +819,69 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
- struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ s32 result;
+ uint32_t vid_idx, vid_bit, mac_index;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+ struct rte_eth_dev_data *data = dev->data;
- PMD_INIT_FUNC_TRACE();
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
/* @todo - add support for the VF */
- if (hw->mac.type != fm10k_mac_pf)
+ if (hw->mac.type != fm10k_mac_pf) {
+ PMD_INIT_LOG(ERR, "VLAN filter not available on VF");
return -ENOTSUP;
+ }
+
+ if (vlan_id > ETH_VLAN_ID_MAX) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: must be < 4096");
+ return (-EINVAL);
+ }
+
+ vid_idx = FM10K_VFTA_IDX(vlan_id);
+ vid_bit = FM10K_VFTA_BIT(vlan_id);
+ /* this VLAN ID is already in the VLAN filter table, return SUCCESS */
+ if (on && (macvlan->vfta[vid_idx] & vid_bit))
+ return 0;
+ /* this VLAN ID is NOT in the VLAN filter table, cannot remove */
+ if (!on && !(macvlan->vfta[vid_idx] & vid_bit)) {
+ PMD_INIT_LOG(ERR, "Invalid vlan_id: not existing "
+ "in the VLAN filter table");
+ return (-EINVAL);
+ }
- return fm10k_update_vlan(hw, vlan_id, 0, on);
+ fm10k_mbx_lock(hw);
+ result = fm10k_update_vlan(hw, vlan_id, 0, on);
+ fm10k_mbx_unlock(hw);
+ if (result != FM10K_SUCCESS) {
+ PMD_INIT_LOG(ERR, "VLAN update failed: %d", result);
+ return (-EIO);
+ }
+
+ for (mac_index = 0; (mac_index < FM10K_MAX_MACADDR_NUM) &&
+ (result == FM10K_SUCCESS); mac_index++) {
+ if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
+ continue;
+ fm10k_mbx_lock(hw);
+ result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
+ data->mac_addrs[mac_index].addr_bytes,
+ vlan_id, on, 0);
+ fm10k_mbx_unlock(hw);
+ }
+ if (result != FM10K_SUCCESS) {
+ PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
+ return (-EIO);
+ }
+
+ if (on) {
+ macvlan->vlan_num++;
+ macvlan->vfta[vid_idx] |= vid_bit;
+ } else {
+ macvlan->vlan_num--;
+ macvlan->vfta[vid_idx] &= ~vid_bit;
+ }
+ return 0;
}
static inline int
@@ -1701,6 +1755,7 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
{
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
int diag;
+ struct fm10k_macvlan_filter_info *macvlan;
PMD_INIT_FUNC_TRACE();
@@ -1715,6 +1770,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+ memset(macvlan, 0, sizeof(*macvlan));
/* Vendor and Device ID need to be set before init of shared code */
memset(hw, 0, sizeof(*hw));
hw->device_id = dev->pci_dev->id.device_id;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 2/3] fm10k: add MAC filter
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
@ 2015-06-18 7:21 ` Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 8:23 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
3 siblings, 0 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-18 7:21 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
MAC filter function was newly added, each PF and VF can have up to 64 MAC
addresses. VF filter needs support from PF host, which is not available now.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k.h | 3 +-
drivers/net/fm10k/fm10k_ethdev.c | 91 ++++++++++++++++++++++++++++++++++++----
2 files changed, 86 insertions(+), 8 deletions(-)
diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 3b95b72..f5be5f8 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -110,7 +110,7 @@
#define FM10K_VLAN_TAG_SIZE 4
/* Maximum number of MAC addresses per PF/VF */
-#define FM10K_MAX_MACADDR_NUM 1
+#define FM10K_MAX_MACADDR_NUM 64
#define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
#define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
@@ -125,6 +125,7 @@
struct fm10k_macvlan_filter_info {
uint16_t vlan_num; /* Total VLAN number */
+ uint16_t mac_num; /* Total mac number */
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 b55a5a7..7925cb7 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -54,6 +54,10 @@
#define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
static void fm10k_close_mbx_service(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_mbx_initlock(struct fm10k_hw *hw)
@@ -668,14 +672,11 @@ fm10k_dev_start(struct rte_eth_dev *dev)
}
if (hw->mac.default_vid && hw->mac.default_vid <= ETHER_MAX_VLAN_ID) {
- fm10k_mbx_lock(hw);
/* Update default vlan */
- hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0, true);
+ fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
/* Add default mac/vlan filter to PF/Switch manger */
- hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map, hw->mac.addr,
- hw->mac.default_vid, true, 0);
- fm10k_mbx_unlock(hw);
+ fm10k_MAC_filter_set(dev, hw->mac.addr, true);
}
return 0;
@@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
dev_info->max_rx_queues = hw->mac.max_queues;
dev_info->max_tx_queues = hw->mac.max_queues;
- dev_info->max_mac_addrs = 1;
+ dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
dev_info->max_hash_mac_addrs = 0;
dev_info->max_vfs = FM10K_MAX_VF_NUM;
dev_info->max_vmdq_pools = ETH_64_POOLS;
@@ -820,6 +821,7 @@ static int
fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
{
s32 result;
+ uint16_t mac_num = 0;
uint32_t vid_idx, vid_bit, mac_index;
struct fm10k_hw *hw;
struct fm10k_macvlan_filter_info *macvlan;
@@ -863,11 +865,17 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
(result == FM10K_SUCCESS); mac_index++) {
if (is_zero_ether_addr(&data->mac_addrs[mac_index]))
continue;
+ if (mac_num > macvlan->mac_num - 1) {
+ PMD_INIT_LOG(ERR, "MAC address number "
+ "not match");
+ break;
+ }
fm10k_mbx_lock(hw);
result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
data->mac_addrs[mac_index].addr_bytes,
vlan_id, on, 0);
fm10k_mbx_unlock(hw);
+ mac_num++;
}
if (result != FM10K_SUCCESS) {
PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
@@ -884,6 +892,72 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return 0;
}
+/* 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 i, j, k;
+ struct fm10k_hw *hw;
+ struct fm10k_macvlan_filter_info *macvlan;
+
+ hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+ macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data->dev_private);
+
+ /* @todo - add support for the VF */
+ if (hw->mac.type != fm10k_mac_pf) {
+ PMD_INIT_LOG(ERR, "MAC filter not available on VF");
+ return;
+ }
+
+ 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 (add)
+ macvlan->mac_num++;
+ else
+ macvlan->mac_num--;
+}
+
+/* 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)
+{
+ fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
+}
+
+/* Remove a MAC address, and update filters */
+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);
+}
+
static inline int
check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
{
@@ -1736,6 +1810,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .mac_addr_add = fm10k_macaddr_add,
+ .mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
.rx_queue_stop = fm10k_dev_rx_queue_stop,
.tx_queue_start = fm10k_dev_tx_queue_start,
@@ -1817,7 +1893,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
}
/* Initialize MAC address(es) */
- dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
+ dev->data->mac_addrs = rte_zmalloc("fm10k",
+ ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
if (dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
return -ENOMEM;
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* [dpdk-dev] [PATCH v3 3/3] fm10k: update VLAN offload features
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 2/3] fm10k: add MAC filter Shaopeng He
@ 2015-06-18 7:21 ` Shaopeng He
2015-06-18 8:23 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
3 siblings, 0 replies; 27+ messages in thread
From: Shaopeng He @ 2015-06-18 7:21 UTC (permalink / raw)
To: dev; +Cc: Shaopeng He
Fm10k PF/VF does not support QinQ; VLAN strip and filter are always on
for PF/VF ports.
Signed-off-by: Shaopeng He <shaopeng.he@intel.com>
---
drivers/net/fm10k/fm10k_ethdev.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 7925cb7..f9584e5 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -787,10 +787,12 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
dev_info->max_vfs = FM10K_MAX_VF_NUM;
dev_info->max_vmdq_pools = ETH_64_POOLS;
dev_info->rx_offload_capa =
+ DEV_RX_OFFLOAD_VLAN_STRIP |
DEV_RX_OFFLOAD_IPV4_CKSUM |
DEV_RX_OFFLOAD_UDP_CKSUM |
DEV_RX_OFFLOAD_TCP_CKSUM;
- dev_info->tx_offload_capa = 0;
+ dev_info->tx_offload_capa =
+ DEV_TX_OFFLOAD_VLAN_INSERT;
dev_info->reta_size = FM10K_MAX_RSS_INDICES;
dev_info->default_rxconf = (struct rte_eth_rxconf) {
@@ -892,6 +894,27 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
return 0;
}
+static void
+fm10k_vlan_offload_set(__rte_unused struct rte_eth_dev *dev, int mask)
+{
+ if (mask & ETH_VLAN_STRIP_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_strip)
+ PMD_INIT_LOG(ERR, "VLAN stripping is "
+ "always on in fm10k");
+ }
+
+ if (mask & ETH_VLAN_EXTEND_MASK) {
+ if (dev->data->dev_conf.rxmode.hw_vlan_extend)
+ PMD_INIT_LOG(ERR, "VLAN QinQ is not "
+ "supported in fm10k");
+ }
+
+ if (mask & ETH_VLAN_FILTER_MASK) {
+ if (!dev->data->dev_conf.rxmode.hw_vlan_filter)
+ PMD_INIT_LOG(ERR, "VLAN filter is always on in fm10k");
+ }
+}
+
/* Add/Remove a MAC address, and update filters */
static void
fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool add)
@@ -1810,6 +1833,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.link_update = fm10k_link_update,
.dev_infos_get = fm10k_dev_infos_get,
.vlan_filter_set = fm10k_vlan_filter_set,
+ .vlan_offload_set = fm10k_vlan_offload_set,
.mac_addr_add = fm10k_macaddr_add,
.mac_addr_remove = fm10k_macaddr_remove,
.rx_queue_start = fm10k_dev_rx_queue_start,
--
1.9.3
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and VLAN offload features
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
` (2 preceding siblings ...)
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 3/3] fm10k: update VLAN offload features Shaopeng He
@ 2015-06-18 8:23 ` Chen, Jing D
2015-06-22 14:21 ` Thomas Monjalon
3 siblings, 1 reply; 27+ messages in thread
From: Chen, Jing D @ 2015-06-18 8:23 UTC (permalink / raw)
To: He, Shaopeng, dev
> -----Original Message-----
> From: He, Shaopeng
> Sent: Thursday, June 18, 2015 3:21 PM
> To: dev@dpdk.org
> Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> Subject: [PATCH v3 0/3] fm10k: update MAC/VLAN filter and VLAN offload
> features
>
> v3 changes:
> - add more result check for MAC table mailbox operation for VLAN filter
> - remove two extra indentation tabs
>
> v2 changes:
> - add result check when updating MAC address table for VLAN filter
> - move VLAN Table updating to the end of VLAN filter process
> - release mailbox lock immediately after each mailbox related operation
> - update the value of rx_offload_capa and tx_offload_capa
> - fix miscelleous review comments
>
> The patch series introduce changes for MAC/VLAN filter and VLAN offload
> features.
> MAC filter is newly added, VLAN filter is updated to add/delete
> one static entry in MAC table for each combination of VLAN and MAC
> address.
> For VLAN offload features, Fm10k PF/VF does not support QinQ;
> and VLAN strip and filter are always on.
>
> Shaopeng He (3):
> fm10k: update VLAN filter
> fm10k: add MAC filter
> fm10k: update VLAN offload features
>
> drivers/net/fm10k/fm10k.h | 24 ++++++
> drivers/net/fm10k/fm10k_ethdev.c | 182
> ++++++++++++++++++++++++++++++++++++---
> 2 files changed, 194 insertions(+), 12 deletions(-)
>
> --
> 1.9.3
Acked-by : Jing Chen <jing.d.chen@intel.com>
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and VLAN offload features
2015-06-18 8:23 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
@ 2015-06-22 14:21 ` Thomas Monjalon
0 siblings, 0 replies; 27+ messages in thread
From: Thomas Monjalon @ 2015-06-22 14:21 UTC (permalink / raw)
To: He, Shaopeng; +Cc: dev
> > v3 changes:
> > - add more result check for MAC table mailbox operation for VLAN filter
> > - remove two extra indentation tabs
> >
> > v2 changes:
> > - add result check when updating MAC address table for VLAN filter
> > - move VLAN Table updating to the end of VLAN filter process
> > - release mailbox lock immediately after each mailbox related operation
> > - update the value of rx_offload_capa and tx_offload_capa
> > - fix miscelleous review comments
> >
> > The patch series introduce changes for MAC/VLAN filter and VLAN offload
> > features.
> > MAC filter is newly added, VLAN filter is updated to add/delete
> > one static entry in MAC table for each combination of VLAN and MAC
> > address.
> > For VLAN offload features, Fm10k PF/VF does not support QinQ;
> > and VLAN strip and filter are always on.
> >
> > Shaopeng He (3):
> > fm10k: update VLAN filter
> > fm10k: add MAC filter
> > fm10k: update VLAN offload features
>
> Acked-by : Jing Chen <jing.d.chen@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2015-06-22 14:22 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 2:58 [dpdk-dev] [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
2015-06-02 2:58 ` [dpdk-dev] [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-09 2:54 ` Chen, Jing D
2015-06-09 7:18 ` He, Shaopeng
2015-06-09 15:51 ` Qiu, Michael
2015-06-10 5:52 ` He, Shaopeng
2015-06-02 2:58 ` [dpdk-dev] [PATCH 2/3] fm10k: add MAC filter Shaopeng He
2015-06-09 3:25 ` Chen, Jing D
2015-06-09 8:31 ` He, Shaopeng
2015-06-09 15:59 ` Qiu, Michael
2015-06-10 1:03 ` He, Shaopeng
2015-06-02 2:58 ` [dpdk-dev] [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-09 3:27 ` Chen, Jing D
2015-06-09 8:55 ` He, Shaopeng
2015-06-09 15:40 ` Qiu, Michael
2015-06-10 6:03 ` He, Shaopeng
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
2015-06-16 12:38 ` Qiu, Michael
2015-06-15 1:23 ` [dpdk-dev] [PATCH v2 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 2/3] fm10k: add MAC filter Shaopeng He
2015-06-18 7:21 ` [dpdk-dev] [PATCH v3 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18 8:23 ` [dpdk-dev] [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
2015-06-22 14:21 ` 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).