* [dpdk-dev] [PATCH 0/8] bnxt patchset
@ 2017-07-20 4:48 Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
` (8 more replies)
0 siblings, 9 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
Hi,
This patch set fixes some of the issues found during testing.
Please apply.
Thanks
net/bnxt: fix log levels for non error conditions.
net/bnxt: fix to avoid a segfault
net/bnxt: fix vnic cleanup
net/bnxt: fix set link config
net/bnxt: reset VF stats during initialization
net/bnxt: fix VLAN antispoof configuration code
net/bnxt: check invalid l2_filter_id
net/bnxt: fix to free a filter before reusing it
drivers/net/bnxt/bnxt.h | 7 +++
drivers/net/bnxt/bnxt_cpr.c | 2 +-
drivers/net/bnxt/bnxt_hwrm.c | 76 ++++++++++++++++++++++-
drivers/net/bnxt/bnxt_hwrm.h | 3 +
drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 +++++++++++++++++++++++-
drivers/net/bnxt/rte_pmd_bnxt.c | 110 ++++++++++++++++++++++-----------
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 1/8] net/bnxt: fix log levels for non error conditions.
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
` (7 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hurd
1) handle_async_event is a DEBUG level log message.
2) Log "Unable to get default VNIC for VF %d" at INFO level.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_cpr.c | 2 +-
drivers/net/bnxt/rte_pmd_bnxt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index f369cf6..68979bc 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -58,7 +58,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
bnxt_link_update_op(bp->eth_dev, 0);
break;
default:
- RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n", event_id);
+ RTE_LOG(DEBUG, PMD, "handle_async_event id = 0x%x\n", event_id);
break;
}
}
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index dd04f58..0a8fb1e 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -333,7 +333,7 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
* This simply indicates there's no driver
* loaded. This is not an error.
*/
- RTE_LOG(ERR, PMD,
+ RTE_LOG(INFO, PMD,
"Unable to get default VNIC for VF %d\n",
vf);
} else {
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 9:56 ` Ferruh Yigit
2017-07-20 4:48 ` [dpdk-dev] [PATCH 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
` (6 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hurd
Fix use of local variable to avoid segfault.
cnt was incorrectly tested and decremented in the loop that removes
a VLAN from the table.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/rte_pmd_bnxt.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index 0a8fb1e..0d48873 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -500,6 +500,7 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
continue;
}
+ /* cnt is one less than vlan_count */
cnt = bp->pf.vf_info[i].vlan_count++;
/*
* And finally, add to the
@@ -511,19 +512,19 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
ve->vid = rte_cpu_to_be_16(vlan);
}
} else {
- for (j = 0; cnt; j++) {
+ for (j = 0; j < cnt; j++) {
if (rte_be_to_cpu_16(
- bp->pf.vf_info[i].vlan_table[j].vid) !=
- vlan)
+ bp->pf.vf_info[i].vlan_table[j].vid) !=
+ vlan)
continue;
memmove(
- &bp->pf.vf_info[i].vlan_table[j],
- &bp->pf.vf_info[i].vlan_table[j + 1],
- getpagesize() -
- ((j + 1) *
+ &bp->pf.vf_info[i].vlan_table[j],
+ &bp->pf.vf_info[i].vlan_table[j + 1],
+ getpagesize() -
+ ((j + 1) *
sizeof(struct bnxt_vlan_table_entry)));
j--;
- cnt = bp->pf.vf_info[i].vlan_count--;
+ cnt = --bp->pf.vf_info[i].vlan_count;
}
}
rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id,
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 3/8] net/bnxt: fix vnic cleanup
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 4/8] net/bnxt: fix set link config Ajit Khaparde
` (5 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
Check if the vnic_id and rss_rule is not invalid before passing it
to the firmware to cleanup the VNIC. Log a message if the vnic_id
is invalid.
Fixes: db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 3583ec7..2c66092 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -980,6 +980,7 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
HWRM_CHECK_RESULT;
vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
+ RTE_LOG(DEBUG, PMD, "VNIC ID %x\n", vnic->fw_vnic_id);
return rc;
}
@@ -1045,6 +1046,11 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
uint32_t ctx_enable_flag = HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE;
struct bnxt_plcmodes_cfg pmodes;
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC ID %x\n", vnic->fw_vnic_id);
+ return rc;
+ }
+
rc = bnxt_hwrm_vnic_plcmodes_qcfg(bp, vnic, &pmodes);
if (rc)
return rc;
@@ -1103,6 +1109,10 @@ int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
struct hwrm_vnic_qcfg_input req = {.req_type = 0 };
struct hwrm_vnic_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC QCFG ID %d\n", vnic->fw_vnic_id);
+ return rc;
+ }
HWRM_PREP(req, VNIC_QCFG, -1, resp);
req.enables =
@@ -1149,6 +1159,7 @@ int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
HWRM_CHECK_RESULT;
vnic->rss_rule = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
+ RTE_LOG(DEBUG, PMD, "VNIC RSS Rule %x\n", vnic->rss_rule);
return rc;
}
@@ -1160,6 +1171,10 @@ int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
bp->hwrm_cmd_resp_addr;
+ if (vnic->rss_rule == 0xffff) {
+ RTE_LOG(DEBUG, PMD, "VNIC RSS Rule %x\n", vnic->rss_rule);
+ return rc;
+ }
HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_FREE, -1, resp);
req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(vnic->rss_rule);
@@ -1179,8 +1194,10 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
struct hwrm_vnic_free_input req = {.req_type = 0 };
struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
- if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC FREE ID %x\n", vnic->fw_vnic_id);
return rc;
+ }
HWRM_PREP(req, VNIC_FREE, -1, resp);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 4/8] net/bnxt: fix set link config
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (2 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
` (4 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
remove the unnecessary rte_delay in bnxt_set_hwrm_link_config
Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 2c66092..7cd4978 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1971,7 +1971,6 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
"Set link config failed with rc %d\n", rc);
}
- rte_delay_ms(BNXT_LINK_WAIT_INTERVAL);
error:
return rc;
}
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 5/8] net/bnxt: reset VF stats during initialization
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (3 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 4/8] net/bnxt: fix set link config Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
` (3 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
This patch resets the VF stats during initialization
Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for
PF/VF")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 7cd4978..231f06b 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -2306,6 +2306,7 @@ int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
reserve_resources_from_vf(bp, &req, i);
bp->pf.active_vfs++;
+ bnxt_hwrm_func_clr_stats(bp, bp->pf.vf_info[i].fid);
}
/*
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 6/8] net/bnxt: fix VLAN antispoof configuration code
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (4 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
` (2 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev; +Cc: Stephen Hurd
We are wrongly using a Rx side HWRM command set_rx_mask to configure
VLAN anti-spoof. This being a Tx side feature, this patch
tries to fix it.
Since the HWRM command to do it ringt is available only in
the newer firmware versions, the patch verifies the firmware
version before attempting to send the HWRM command to
the firmware.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt.h | 7 +++
drivers/net/bnxt/bnxt_hwrm.c | 49 ++++++++++++++++++
drivers/net/bnxt/bnxt_hwrm.h | 3 ++
drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 ++++++++++++++++++++++++++++-
drivers/net/bnxt/rte_pmd_bnxt.c | 93 +++++++++++++++++++++++-----------
5 files changed, 203 insertions(+), 30 deletions(-)
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index ec1aad9..405d94d 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -97,9 +97,16 @@ struct bnxt_vlan_table_entry {
uint16_t vid;
} __attribute__((packed));
+struct bnxt_vlan_antispoof_table_entry {
+ uint16_t tpid;
+ uint16_t vid;
+ uint16_t mask;
+} __attribute__((packed));
+
struct bnxt_child_vf_info {
void *req_buf;
struct bnxt_vlan_table_entry *vlan_table;
+ struct bnxt_vlan_antispoof_table_entry *vlan_as_table;
STAILQ_HEAD(, bnxt_filter_info) filter;
uint32_t func_cfg_flags;
uint32_t l2_rx_mask;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 231f06b..a82cc81 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -282,6 +282,44 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
return rc;
}
+int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
+ uint16_t vlan_count,
+ struct bnxt_vlan_antispoof_table_entry *vlan_table)
+{
+ int rc = 0;
+ struct hwrm_cfa_vlan_antispoof_cfg_input req = {.req_type = 0 };
+ struct hwrm_cfa_vlan_antispoof_cfg_output *resp =
+ bp->hwrm_cmd_resp_addr;
+
+ /*
+ * Older HWRM versions did not support this command, and the set_rx_mask
+ * list was used for anti-spoof. In 1.8.0, the TX path configuration was
+ * removed from set_rx_mask call, and this command was added.
+ *
+ * This command is also present from 1.7.8.11 and higher,
+ * as well as 1.7.8.0
+ */
+ if (bp->fw_ver < ((1 << 24) | (8 << 16))) {
+ if (bp->fw_ver != ((1 << 24) | (7 << 16) | (8 << 8))) {
+ if (bp->fw_ver < ((1 << 24) | (7 << 16) | (8 << 8) |
+ (11)))
+ return 0;
+ }
+ }
+ HWRM_PREP(req, CFA_VLAN_ANTISPOOF_CFG, -1, resp);
+ req.fid = rte_cpu_to_le_16(fid);
+
+ req.vlan_tag_mask_tbl_addr =
+ rte_cpu_to_le_64(rte_mem_virt2phy(vlan_table));
+ req.num_vlan_entries = rte_cpu_to_le_32((uint32_t)vlan_count);
+
+ rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
+
+ HWRM_CHECK_RESULT;
+
+ return rc;
+}
+
int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct bnxt_filter_info *filter)
{
@@ -389,6 +427,17 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
else
rte_mem_lock_page(
bp->pf.vf_info[i].vlan_table);
+ bp->pf.vf_info[i].vlan_as_table =
+ rte_zmalloc("VF VLAN AS table",
+ getpagesize(),
+ getpagesize());
+ if (bp->pf.vf_info[i].vlan_as_table == NULL)
+ RTE_LOG(ERR, PMD,
+ "Alloc VLAN AS table for VF %d fail\n",
+ i);
+ else
+ rte_mem_lock_page(
+ bp->pf.vf_info[i].vlan_as_table);
STAILQ_INIT(&bp->pf.vf_info[i].filter);
}
}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index dd0999a..51cd0dd 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -48,6 +48,9 @@ int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp,
int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic,
uint16_t vlan_count,
struct bnxt_vlan_table_entry *vlan_table);
+int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
+ uint16_t vlan_count,
+ struct bnxt_vlan_antispoof_table_entry *vlan_table);
int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct bnxt_filter_info *filter);
int bnxt_hwrm_set_filter(struct bnxt *bp,
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 1eb8d33..cb8660a 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -123,7 +123,7 @@
#define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
#define HWRM_CFA_L2_SET_RX_MASK (UINT32_C(0x93))
/* Reserved for future use */
-#define RESERVED4 (UINT32_C(0x94))
+#define HWRM_CFA_VLAN_ANTISPOOF_CFG (UINT32_C(0x94))
#define HWRM_CFA_TUNNEL_FILTER_ALLOC (UINT32_C(0x95))
#define HWRM_CFA_TUNNEL_FILTER_FREE (UINT32_C(0x96))
#define HWRM_CFA_NTUPLE_FILTER_ALLOC (UINT32_C(0x99))
@@ -9471,6 +9471,85 @@ struct hwrm_cfa_l2_set_rx_mask_output {
*/
} __attribute__((packed));
+/* hwrm_cfa_vlan_antispoof_cfg */
+/* Description: Configures vlan anti-spoof filters for VF. */
+/* Input (32 bytes) */
+struct hwrm_cfa_vlan_antispoof_cfg_input {
+ uint16_t req_type;
+ /*
+ * This value indicates what type of request this is. The format for the
+ * rest of the command is determined by this field.
+ */
+ uint16_t cmpl_ring;
+ /*
+ * This value indicates the what completion ring the request will be
+ * optionally completed on. If the value is -1, then no CR completion
+ * will be generated. Any other value must be a valid CR ring_id value
+ * for this function.
+ */
+ uint16_t seq_id;
+ /* This value indicates the command sequence number. */
+ uint16_t target_id;
+ /*
+ * Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+ * 0xFFF8 - 0xFFFE - Reserved for internal processors 0xFFFF - HWRM
+ */
+ uint64_t resp_addr;
+ /*
+ * This is the host address where the response will be written when the
+ * request is complete. This area must be 16B aligned and must be
+ * cleared to zero before the request is made.
+ */
+ uint16_t fid;
+ /*
+ * Function ID of the function that is being configured. Only valid for
+ * a VF FID configured by the PF.
+ */
+ uint8_t unused_0;
+ uint8_t unused_1;
+ uint32_t num_vlan_entries;
+ /* Number of VLAN entries in the vlan_tag_mask_tbl. */
+ uint64_t vlan_tag_mask_tbl_addr;
+ /*
+ * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN antispoof
+ * table. Each table entry contains the 16-bit TPID (0x8100 or 0x88a8
+ * only), 16-bit VLAN ID, and a 16-bit mask, all in network order to
+ * match hwrm_cfa_l2_set_rx_mask. For an individual VLAN entry, the mask
+ * value should be 0xfff for the 12-bit VLAN ID.
+ */
+};
+
+/* Output (16 bytes) */
+struct hwrm_cfa_vlan_antispoof_cfg_output {
+ uint16_t error_code;
+ /*
+ * Pass/Fail or error type Note: receiver to verify the in parameters,
+ * and fail the call with an error when appropriate
+ */
+ uint16_t req_type;
+ /* This field returns the type of original request. */
+ uint16_t seq_id;
+ /* This field provides original sequence number of the command. */
+ uint16_t resp_len;
+ /*
+ * This field is the length of the response in bytes. The last byte of
+ * the response is a valid flag that will read as '1' when the command
+ * has been completely written to memory.
+ */
+ uint32_t unused_0;
+ uint8_t unused_1;
+ uint8_t unused_2;
+ uint8_t unused_3;
+ uint8_t valid;
+ /*
+ * This field is used in Output records to indicate that the output is
+ * completely written to RAM. This field should be read as '1' to
+ * indicate that the output has been completely written. When writing a
+ * command completion or response to an internal processor, the order of
+ * writes has to be such that this field is written last.
+ */
+};
+
/* hwrm_tunnel_dst_port_query */
/*
* Description: This function is called by a driver to query tunnel type
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index 0d48873..b43ef9c 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -299,8 +299,6 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
struct rte_eth_dev *dev;
struct bnxt *bp;
int rc;
- int dflt_vnic;
- struct bnxt_vnic_info vnic;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
@@ -327,25 +325,11 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
if (!rc) {
bp->pf.vf_info[vf].vlan_spoof_en = on;
if (on) {
- dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf);
- if (dflt_vnic < 0) {
- /*
- * This simply indicates there's no driver
- * loaded. This is not an error.
- */
- RTE_LOG(INFO, PMD,
- "Unable to get default VNIC for VF %d\n",
- vf);
- } else {
- vnic.fw_vnic_id = dflt_vnic;
- if (bnxt_hwrm_vnic_qcfg(bp,
- &vnic, bp->pf.first_vf_id + vf) == 0) {
- if (bnxt_hwrm_cfa_l2_set_rx_mask(bp,
- &vnic, bp->pf.vf_info[vf].vlan_count,
- bp->pf.vf_info[vf].vlan_table))
- rc = -1;
- }
- }
+ if (bnxt_hwrm_cfa_vlan_antispoof_cfg(bp,
+ bp->pf.first_vf_id + vf,
+ bp->pf.vf_info[vf].vlan_count,
+ bp->pf.vf_info[vf].vlan_as_table))
+ rc = -1;
}
} else {
RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", vf);
@@ -451,10 +435,47 @@ int rte_pmd_bnxt_set_vf_rxmode(uint8_t port, uint16_t vf,
return rc;
}
+static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf)
+{
+ int rc;
+ int dflt_vnic;
+ struct bnxt_vnic_info vnic;
+
+ if (!BNXT_PF(bp)) {
+ RTE_LOG(ERR, PMD,
+ "Attempt to set VLAN table on non-PF port!\n");
+ return -EINVAL;
+ }
+
+ if (vf >= bp->pdev->max_vfs)
+ return -EINVAL;
+
+ dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf);
+ if (dflt_vnic < 0) {
+ /* This simply indicates there's no driver loaded.
+ * This is not an error.
+ */
+ RTE_LOG(ERR, PMD, "Unable to get default VNIC for VF %d\n", vf);
+ } else {
+ memset(&vnic, 0, sizeof(vnic));
+ vnic.fw_vnic_id = dflt_vnic;
+ if (bnxt_hwrm_vnic_qcfg(bp, &vnic,
+ bp->pf.first_vf_id + vf) == 0) {
+ if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic,
+ bp->pf.vf_info[vf].vlan_count,
+ bp->pf.vf_info[vf].vlan_table))
+ rc = -1;
+ }
+ }
+
+ return rc;
+}
+
int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
uint64_t vf_mask, uint8_t vlan_on)
{
struct bnxt_vlan_table_entry *ve;
+ struct bnxt_vlan_antispoof_table_entry *vase;
struct rte_eth_dev *dev;
struct bnxt *bp;
uint16_t cnt;
@@ -478,6 +499,10 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
rc = -1;
continue;
}
+ if (bp->pf.vf_info[i].vlan_as_table == NULL) {
+ rc = -1;
+ continue;
+ }
if (vlan_on) {
/* First, search for a duplicate... */
for (j = 0; j < cnt; j++) {
@@ -488,14 +513,13 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
}
if (j == cnt) {
/* Now check that there's space */
- if (cnt == getpagesize() /
- sizeof(struct bnxt_vlan_table_entry)) {
+ if (cnt == getpagesize() / sizeof(struct
+ bnxt_vlan_antispoof_table_entry)) {
RTE_LOG(ERR, PMD,
- "VF %d VLAN table is full\n",
- i);
+ "VLAN anti-spoof table is full\n");
RTE_LOG(ERR, PMD,
- "cannot add VLAN %u\n",
- vlan);
+ "VF %d cannot add VLAN %u\n",
+ i, vlan);
rc = -1;
continue;
}
@@ -506,6 +530,12 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
* And finally, add to the
* end of the table
*/
+ vase =
+ &bp->pf.vf_info[i].vlan_as_table[cnt];
+ // TODO: Hardcoded TPID
+ vase->tpid = rte_cpu_to_be_16(0x8100);
+ vase->vid = rte_cpu_to_be_16(vlan);
+ vase->mask = rte_cpu_to_be_16(0xfff);
ve = &bp->pf.vf_info[i].vlan_table[cnt];
/* TODO: Hardcoded TPID */
ve->tpid = rte_cpu_to_be_16(0x8100);
@@ -523,12 +553,17 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
getpagesize() -
((j + 1) *
sizeof(struct bnxt_vlan_table_entry)));
+ memmove(
+ &bp->pf.vf_info[i].vlan_as_table[j],
+ &bp->pf.vf_info[i].vlan_as_table[j + 1],
+ getpagesize() -
+ ((j + 1) * sizeof(struct
+ bnxt_vlan_antispoof_table_entry)));
j--;
cnt = --bp->pf.vf_info[i].vlan_count;
}
}
- rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id,
- i, bp->pf.vf_info[i].vlan_spoof_en);
+ bnxt_set_vf_table(bp, i);
}
}
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 7/8] net/bnxt: check invalid l2_filter_id
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (5 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
2017-07-20 10:02 ` [dpdk-dev] [PATCH 0/8] bnxt patchset Ferruh Yigit
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
Add code to check for invalid filter_id in bnxt_hwrm_clear_filter
Fixes: f92735db1e4c ("net/bnxt: add L2 filter alloc/init/free")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index a82cc81..e230b46 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -327,6 +327,9 @@ int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 };
struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;
+ if (filter->fw_l2_filter_id == UINT64_MAX)
+ return 0;
+
HWRM_PREP(req, CFA_L2_FILTER_FREE, -1, resp);
req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH 8/8] net/bnxt: fix to free a filter before reusing it
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (6 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
@ 2017-07-20 4:48 ` Ajit Khaparde
2017-07-20 10:02 ` [dpdk-dev] [PATCH 0/8] bnxt patchset Ferruh Yigit
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-20 4:48 UTC (permalink / raw)
To: dev
This patch sends the HWRM command to free a filter in the hardware,
before using it again.
Fixes: f92735db1e4c ("net/bnxt: add L2 filter alloc/init/free")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index e230b46..4b1810c 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -352,6 +352,9 @@ int bnxt_hwrm_set_filter(struct bnxt *bp,
struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
uint32_t enables = 0;
+ if (filter->fw_l2_filter_id != UINT64_MAX)
+ bnxt_hwrm_clear_filter(bp, filter);
+
HWRM_PREP(req, CFA_L2_FILTER_ALLOC, -1, resp);
req.flags = rte_cpu_to_le_32(filter->flags);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault
2017-07-20 4:48 ` [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
@ 2017-07-20 9:56 ` Ferruh Yigit
0 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2017-07-20 9:56 UTC (permalink / raw)
To: Ajit Khaparde, dev; +Cc: Stephen Hurd
On 7/20/2017 5:48 AM, Ajit Khaparde wrote:
> Fix use of local variable to avoid segfault.
> cnt was incorrectly tested and decremented in the loop that removes
> a VLAN from the table.
>
> Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
>
> Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> ---
> drivers/net/bnxt/rte_pmd_bnxt.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
> index 0a8fb1e..0d48873 100644
> --- a/drivers/net/bnxt/rte_pmd_bnxt.c
> +++ b/drivers/net/bnxt/rte_pmd_bnxt.c
> @@ -500,6 +500,7 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
> continue;
> }
>
> + /* cnt is one less than vlan_count */
> cnt = bp->pf.vf_info[i].vlan_count++;
> /*
> * And finally, add to the
> @@ -511,19 +512,19 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
> ve->vid = rte_cpu_to_be_16(vlan);
> }
> } else {
> - for (j = 0; cnt; j++) {
> + for (j = 0; j < cnt; j++) {
> if (rte_be_to_cpu_16(
> - bp->pf.vf_info[i].vlan_table[j].vid) !=
> - vlan)
> + bp->pf.vf_info[i].vlan_table[j].vid) !=
> + vlan)
> continue;
> memmove(
> - &bp->pf.vf_info[i].vlan_table[j],
> - &bp->pf.vf_info[i].vlan_table[j + 1],
I may be missing something but if &bp->pf.vf_info[i].vlan_table[j +
1].vid == vlan, this may be endless loop.
because each time vlan_table[j + 1] copied into vlan_table[j] and j--,
in next iteration same thing will happen.
> - getpagesize() -
> - ((j + 1) *
> + &bp->pf.vf_info[i].vlan_table[j],
> + &bp->pf.vf_info[i].vlan_table[j + 1],
I guess line realigned to fit into 80 characters limitation, one of the
good thing with 80 chars limitation is it forces to reduce indention.
It is up to you, but if you do following, it can be possible to reduce
the indention one level and it will be easier to fit into limit:
if.((vf_mask.&.1) == 0)
continue;
> + getpagesize() -
> + ((j + 1) *
> sizeof(struct bnxt_vlan_table_entry)));
> j--;
> - cnt = bp->pf.vf_info[i].vlan_count--;
> + cnt = --bp->pf.vf_info[i].vlan_count;
> }
> }
> rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id,
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [dpdk-dev] [PATCH 0/8] bnxt patchset
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
` (7 preceding siblings ...)
2017-07-20 4:48 ` [dpdk-dev] [PATCH 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
@ 2017-07-20 10:02 ` Ferruh Yigit
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
8 siblings, 1 reply; 22+ messages in thread
From: Ferruh Yigit @ 2017-07-20 10:02 UTC (permalink / raw)
To: Ajit Khaparde, dev
On 7/20/2017 5:48 AM, Ajit Khaparde wrote:
> Hi,
> This patch set fixes some of the issues found during testing.
> Please apply.
>
> Thanks
>
> net/bnxt: fix log levels for non error conditions.
> net/bnxt: fix to avoid a segfault
> net/bnxt: fix vnic cleanup
> net/bnxt: fix set link config
> net/bnxt: reset VF stats during initialization
> net/bnxt: fix VLAN antispoof configuration code
> net/bnxt: check invalid l2_filter_id
> net/bnxt: fix to free a filter before reusing it
Getting following build errors, fyi:
.../drivers/net/bnxt/rte_pmd_bnxt.c:464:8: error: variable 'rc' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:471:9: note: uninitialized use
occurs here
return rc;
^~
.../drivers/net/bnxt/rte_pmd_bnxt.c:464:4: note: remove the 'if' if its
condition is always true
if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:462:7: error: variable 'rc' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (bnxt_hwrm_vnic_qcfg(bp, &vnic,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:471:9: note: uninitialized use
occurs here
return rc;
^~
.../drivers/net/bnxt/rte_pmd_bnxt.c:462:3: note: remove the 'if' if its
condition is always true
if (bnxt_hwrm_vnic_qcfg(bp, &vnic,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:454:6: error: variable 'rc' is used
uninitialized whenever 'if' condition is true
[-Werror,-Wsometimes-uninitialized]
if (dflt_vnic < 0) {
^~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:471:9: note: uninitialized use
occurs here
return rc;
^~
.../drivers/net/bnxt/rte_pmd_bnxt.c:454:2: note: remove the 'if' if its
condition is always false
if (dflt_vnic < 0) {
^~~~~~~~~~~~~~~~~~~~
.../drivers/net/bnxt/rte_pmd_bnxt.c:440:8: note: initialize the variable
'rc' to silence this warning
int rc;
^
= 0
3 errors generated.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 0/8] bnxt patchset
2017-07-20 10:02 ` [dpdk-dev] [PATCH 0/8] bnxt patchset Ferruh Yigit
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
` (8 more replies)
0 siblings, 9 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
This patch set fixes some of the issues found during testing.
Please apply.
v1->v2: incorporate review feedback
net/bnxt: fix log levels for non error conditions.
net/bnxt: fix to avoid a segfault
net/bnxt: fix vnic cleanup
net/bnxt: fix set link config
net/bnxt: reset VF stats during initialization
net/bnxt: fix VLAN antispoof configuration code
net/bnxt: check invalid l2_filter_id
net/bnxt: fix to free a filter before reusing it
drivers/net/bnxt/bnxt.h | 7 ++
drivers/net/bnxt/bnxt_cpr.c | 2 +-
drivers/net/bnxt/bnxt_hwrm.c | 76 +++++++++++-
drivers/net/bnxt/bnxt_hwrm.h | 3 +
drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 ++++++++++++-
drivers/net/bnxt/rte_pmd_bnxt.c | 178 ++++++++++++++++------------
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 1/8] net/bnxt: fix log levels for non error conditions.
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
` (7 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Stephen Hurd
1) handle_async_event is a DEBUG level log message.
2) Log "Unable to get default VNIC for VF %d" at INFO level.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_cpr.c | 2 +-
drivers/net/bnxt/rte_pmd_bnxt.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c
index f369cf6..68979bc 100644
--- a/drivers/net/bnxt/bnxt_cpr.c
+++ b/drivers/net/bnxt/bnxt_cpr.c
@@ -58,7 +58,7 @@ void bnxt_handle_async_event(struct bnxt *bp,
bnxt_link_update_op(bp->eth_dev, 0);
break;
default:
- RTE_LOG(ERR, PMD, "handle_async_event id = 0x%x\n", event_id);
+ RTE_LOG(DEBUG, PMD, "handle_async_event id = 0x%x\n", event_id);
break;
}
}
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index dd04f58..0a8fb1e 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -333,7 +333,7 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
* This simply indicates there's no driver
* loaded. This is not an error.
*/
- RTE_LOG(ERR, PMD,
+ RTE_LOG(INFO, PMD,
"Unable to get default VNIC for VF %d\n",
vf);
} else {
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 19:09 ` Stephen Hurd
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
` (6 subsequent siblings)
8 siblings, 1 reply; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Stephen Hurd
Fix use of local variable to avoid segfault.
cnt was incorrectly tested and decremented in the loop that removes
a VLAN from the table.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
--
v1->v2: incorporate review feedback.
---
drivers/net/bnxt/rte_pmd_bnxt.c | 101 +++++++++++++++++++---------------------
1 file changed, 49 insertions(+), 52 deletions(-)
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index 0a8fb1e..ec5855d 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -473,62 +473,59 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
for (i = 0; vf_mask; i++, vf_mask >>= 1) {
cnt = bp->pf.vf_info[i].vlan_count;
- if (vf_mask & 1) {
- if (bp->pf.vf_info[i].vlan_table == NULL) {
- rc = -1;
- continue;
+ if ((vf_mask & 1) == 0)
+ continue;
+
+ if (bp->pf.vf_info[i].vlan_table == NULL) {
+ rc = -1;
+ continue;
+ }
+ if (vlan_on) {
+ /* First, search for a duplicate... */
+ for (j = 0; j < cnt; j++) {
+ if (rte_be_to_cpu_16(
+ bp->pf.vf_info[i].vlan_table[j].vid) == vlan)
+ break;
}
- if (vlan_on) {
- /* First, search for a duplicate... */
- for (j = 0; j < cnt; j++) {
- if (rte_be_to_cpu_16(
- bp->pf.vf_info[i].vlan_table[j].vid) ==
- vlan)
- break;
- }
- if (j == cnt) {
- /* Now check that there's space */
- if (cnt == getpagesize() /
- sizeof(struct bnxt_vlan_table_entry)) {
- RTE_LOG(ERR, PMD,
- "VF %d VLAN table is full\n",
- i);
- RTE_LOG(ERR, PMD,
- "cannot add VLAN %u\n",
- vlan);
- rc = -1;
- continue;
- }
-
- cnt = bp->pf.vf_info[i].vlan_count++;
- /*
- * And finally, add to the
- * end of the table
- */
- ve = &bp->pf.vf_info[i].vlan_table[cnt];
- /* TODO: Hardcoded TPID */
- ve->tpid = rte_cpu_to_be_16(0x8100);
- ve->vid = rte_cpu_to_be_16(vlan);
- }
- } else {
- for (j = 0; cnt; j++) {
- if (rte_be_to_cpu_16(
- bp->pf.vf_info[i].vlan_table[j].vid) !=
- vlan)
- continue;
- memmove(
- &bp->pf.vf_info[i].vlan_table[j],
- &bp->pf.vf_info[i].vlan_table[j + 1],
- getpagesize() -
- ((j + 1) *
- sizeof(struct bnxt_vlan_table_entry)));
- j--;
- cnt = bp->pf.vf_info[i].vlan_count--;
+ if (j == cnt) {
+ /* Now check that there's space */
+ if (cnt == getpagesize() /
+ sizeof(struct bnxt_vlan_table_entry)) {
+ RTE_LOG(ERR, PMD,
+ "VF %d VLAN table is full\n",
+ i);
+ RTE_LOG(ERR, PMD,
+ "cannot add VLAN %u\n", vlan);
+ rc = -1;
+ continue;
}
+
+ /* cnt is one less than vlan_count */
+ cnt = bp->pf.vf_info[i].vlan_count++;
+ /*
+ * And finally, add to the
+ * end of the table
+ */
+ ve = &bp->pf.vf_info[i].vlan_table[cnt];
+ /* TODO: Hardcoded TPID */
+ ve->tpid = rte_cpu_to_be_16(0x8100);
+ ve->vid = rte_cpu_to_be_16(vlan);
+ }
+ } else {
+ for (j = 0; j < cnt; j++) {
+ if (rte_be_to_cpu_16(
+ bp->pf.vf_info[i].vlan_table[j].vid) != vlan)
+ continue;
+ memmove(&bp->pf.vf_info[i].vlan_table[j],
+ &bp->pf.vf_info[i].vlan_table[j + 1],
+ getpagesize() - ((j + 1) *
+ sizeof(struct bnxt_vlan_table_entry)));
+ j--;
+ cnt = --bp->pf.vf_info[i].vlan_count;
}
- rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id,
- i, bp->pf.vf_info[i].vlan_spoof_en);
}
+ rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id, i,
+ bp->pf.vf_info[i].vlan_spoof_en);
}
return rc;
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 3/8] net/bnxt: fix vnic cleanup
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 4/8] net/bnxt: fix set link config Ajit Khaparde
` (5 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
Check if the vnic_id and rss_rule is not invalid before passing it
to the firmware to cleanup the VNIC. Log a message if the vnic_id
is invalid.
Fixes: db678d5c2b54 ("net/bnxt: add HWRM VNIC configure")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 3583ec7..2c66092 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -980,6 +980,7 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
HWRM_CHECK_RESULT;
vnic->fw_vnic_id = rte_le_to_cpu_16(resp->vnic_id);
+ RTE_LOG(DEBUG, PMD, "VNIC ID %x\n", vnic->fw_vnic_id);
return rc;
}
@@ -1045,6 +1046,11 @@ int bnxt_hwrm_vnic_cfg(struct bnxt *bp, struct bnxt_vnic_info *vnic)
uint32_t ctx_enable_flag = HWRM_VNIC_CFG_INPUT_ENABLES_RSS_RULE;
struct bnxt_plcmodes_cfg pmodes;
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC ID %x\n", vnic->fw_vnic_id);
+ return rc;
+ }
+
rc = bnxt_hwrm_vnic_plcmodes_qcfg(bp, vnic, &pmodes);
if (rc)
return rc;
@@ -1103,6 +1109,10 @@ int bnxt_hwrm_vnic_qcfg(struct bnxt *bp, struct bnxt_vnic_info *vnic,
struct hwrm_vnic_qcfg_input req = {.req_type = 0 };
struct hwrm_vnic_qcfg_output *resp = bp->hwrm_cmd_resp_addr;
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC QCFG ID %d\n", vnic->fw_vnic_id);
+ return rc;
+ }
HWRM_PREP(req, VNIC_QCFG, -1, resp);
req.enables =
@@ -1149,6 +1159,7 @@ int bnxt_hwrm_vnic_ctx_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic)
HWRM_CHECK_RESULT;
vnic->rss_rule = rte_le_to_cpu_16(resp->rss_cos_lb_ctx_id);
+ RTE_LOG(DEBUG, PMD, "VNIC RSS Rule %x\n", vnic->rss_rule);
return rc;
}
@@ -1160,6 +1171,10 @@ int bnxt_hwrm_vnic_ctx_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
struct hwrm_vnic_rss_cos_lb_ctx_free_output *resp =
bp->hwrm_cmd_resp_addr;
+ if (vnic->rss_rule == 0xffff) {
+ RTE_LOG(DEBUG, PMD, "VNIC RSS Rule %x\n", vnic->rss_rule);
+ return rc;
+ }
HWRM_PREP(req, VNIC_RSS_COS_LB_CTX_FREE, -1, resp);
req.rss_cos_lb_ctx_id = rte_cpu_to_le_16(vnic->rss_rule);
@@ -1179,8 +1194,10 @@ int bnxt_hwrm_vnic_free(struct bnxt *bp, struct bnxt_vnic_info *vnic)
struct hwrm_vnic_free_input req = {.req_type = 0 };
struct hwrm_vnic_free_output *resp = bp->hwrm_cmd_resp_addr;
- if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+ if (vnic->fw_vnic_id == INVALID_HW_RING_ID) {
+ RTE_LOG(DEBUG, PMD, "VNIC FREE ID %x\n", vnic->fw_vnic_id);
return rc;
+ }
HWRM_PREP(req, VNIC_FREE, -1, resp);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 4/8] net/bnxt: fix set link config
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (2 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
` (4 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
remove the unnecessary rte_delay in bnxt_set_hwrm_link_config
Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 2c66092..7cd4978 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -1971,7 +1971,6 @@ int bnxt_set_hwrm_link_config(struct bnxt *bp, bool link_up)
"Set link config failed with rc %d\n", rc);
}
- rte_delay_ms(BNXT_LINK_WAIT_INTERVAL);
error:
return rc;
}
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 5/8] net/bnxt: reset VF stats during initialization
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (3 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 4/8] net/bnxt: fix set link config Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
` (3 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
This patch resets the VF stats during initialization
Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for
PF/VF")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 7cd4978..231f06b 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -2306,6 +2306,7 @@ int bnxt_hwrm_allocate_vfs(struct bnxt *bp, int num_vfs)
reserve_resources_from_vf(bp, &req, i);
bp->pf.active_vfs++;
+ bnxt_hwrm_func_clr_stats(bp, bp->pf.vf_info[i].fid);
}
/*
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 6/8] net/bnxt: fix VLAN antispoof configuration code
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (4 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
` (2 subsequent siblings)
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Stephen Hurd
We are wrongly using a Rx side HWRM command set_rx_mask to configure
VLAN anti-spoof. This being a Tx side feature, this patch
tries to fix it.
Since the HWRM command to do it ringt is available only in
the newer firmware versions, the patch verifies the firmware
version before attempting to send the HWRM command to
the firmware.
Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
--
v1->v2: incorporate review feedback
---
drivers/net/bnxt/bnxt.h | 7 +++
drivers/net/bnxt/bnxt_hwrm.c | 49 ++++++++++++++++++
drivers/net/bnxt/bnxt_hwrm.h | 3 ++
drivers/net/bnxt/hsi_struct_def_dpdk.h | 81 +++++++++++++++++++++++++++++-
drivers/net/bnxt/rte_pmd_bnxt.c | 91 +++++++++++++++++++++++-----------
5 files changed, 202 insertions(+), 29 deletions(-)
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index ec1aad9..405d94d 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -97,9 +97,16 @@ struct bnxt_vlan_table_entry {
uint16_t vid;
} __attribute__((packed));
+struct bnxt_vlan_antispoof_table_entry {
+ uint16_t tpid;
+ uint16_t vid;
+ uint16_t mask;
+} __attribute__((packed));
+
struct bnxt_child_vf_info {
void *req_buf;
struct bnxt_vlan_table_entry *vlan_table;
+ struct bnxt_vlan_antispoof_table_entry *vlan_as_table;
STAILQ_HEAD(, bnxt_filter_info) filter;
uint32_t func_cfg_flags;
uint32_t l2_rx_mask;
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 231f06b..a82cc81 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -282,6 +282,44 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
return rc;
}
+int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
+ uint16_t vlan_count,
+ struct bnxt_vlan_antispoof_table_entry *vlan_table)
+{
+ int rc = 0;
+ struct hwrm_cfa_vlan_antispoof_cfg_input req = {.req_type = 0 };
+ struct hwrm_cfa_vlan_antispoof_cfg_output *resp =
+ bp->hwrm_cmd_resp_addr;
+
+ /*
+ * Older HWRM versions did not support this command, and the set_rx_mask
+ * list was used for anti-spoof. In 1.8.0, the TX path configuration was
+ * removed from set_rx_mask call, and this command was added.
+ *
+ * This command is also present from 1.7.8.11 and higher,
+ * as well as 1.7.8.0
+ */
+ if (bp->fw_ver < ((1 << 24) | (8 << 16))) {
+ if (bp->fw_ver != ((1 << 24) | (7 << 16) | (8 << 8))) {
+ if (bp->fw_ver < ((1 << 24) | (7 << 16) | (8 << 8) |
+ (11)))
+ return 0;
+ }
+ }
+ HWRM_PREP(req, CFA_VLAN_ANTISPOOF_CFG, -1, resp);
+ req.fid = rte_cpu_to_le_16(fid);
+
+ req.vlan_tag_mask_tbl_addr =
+ rte_cpu_to_le_64(rte_mem_virt2phy(vlan_table));
+ req.num_vlan_entries = rte_cpu_to_le_32((uint32_t)vlan_count);
+
+ rc = bnxt_hwrm_send_message(bp, &req, sizeof(req));
+
+ HWRM_CHECK_RESULT;
+
+ return rc;
+}
+
int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct bnxt_filter_info *filter)
{
@@ -389,6 +427,17 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
else
rte_mem_lock_page(
bp->pf.vf_info[i].vlan_table);
+ bp->pf.vf_info[i].vlan_as_table =
+ rte_zmalloc("VF VLAN AS table",
+ getpagesize(),
+ getpagesize());
+ if (bp->pf.vf_info[i].vlan_as_table == NULL)
+ RTE_LOG(ERR, PMD,
+ "Alloc VLAN AS table for VF %d fail\n",
+ i);
+ else
+ rte_mem_lock_page(
+ bp->pf.vf_info[i].vlan_as_table);
STAILQ_INIT(&bp->pf.vf_info[i].filter);
}
}
diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h
index dd0999a..51cd0dd 100644
--- a/drivers/net/bnxt/bnxt_hwrm.h
+++ b/drivers/net/bnxt/bnxt_hwrm.h
@@ -48,6 +48,9 @@ int bnxt_hwrm_cfa_l2_clear_rx_mask(struct bnxt *bp,
int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic,
uint16_t vlan_count,
struct bnxt_vlan_table_entry *vlan_table);
+int bnxt_hwrm_cfa_vlan_antispoof_cfg(struct bnxt *bp, uint16_t fid,
+ uint16_t vlan_count,
+ struct bnxt_vlan_antispoof_table_entry *vlan_table);
int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct bnxt_filter_info *filter);
int bnxt_hwrm_set_filter(struct bnxt *bp,
diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h
index 1eb8d33..cb8660a 100644
--- a/drivers/net/bnxt/hsi_struct_def_dpdk.h
+++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h
@@ -123,7 +123,7 @@
#define HWRM_CFA_L2_FILTER_CFG (UINT32_C(0x92))
#define HWRM_CFA_L2_SET_RX_MASK (UINT32_C(0x93))
/* Reserved for future use */
-#define RESERVED4 (UINT32_C(0x94))
+#define HWRM_CFA_VLAN_ANTISPOOF_CFG (UINT32_C(0x94))
#define HWRM_CFA_TUNNEL_FILTER_ALLOC (UINT32_C(0x95))
#define HWRM_CFA_TUNNEL_FILTER_FREE (UINT32_C(0x96))
#define HWRM_CFA_NTUPLE_FILTER_ALLOC (UINT32_C(0x99))
@@ -9471,6 +9471,85 @@ struct hwrm_cfa_l2_set_rx_mask_output {
*/
} __attribute__((packed));
+/* hwrm_cfa_vlan_antispoof_cfg */
+/* Description: Configures vlan anti-spoof filters for VF. */
+/* Input (32 bytes) */
+struct hwrm_cfa_vlan_antispoof_cfg_input {
+ uint16_t req_type;
+ /*
+ * This value indicates what type of request this is. The format for the
+ * rest of the command is determined by this field.
+ */
+ uint16_t cmpl_ring;
+ /*
+ * This value indicates the what completion ring the request will be
+ * optionally completed on. If the value is -1, then no CR completion
+ * will be generated. Any other value must be a valid CR ring_id value
+ * for this function.
+ */
+ uint16_t seq_id;
+ /* This value indicates the command sequence number. */
+ uint16_t target_id;
+ /*
+ * Target ID of this command. 0x0 - 0xFFF8 - Used for function ids
+ * 0xFFF8 - 0xFFFE - Reserved for internal processors 0xFFFF - HWRM
+ */
+ uint64_t resp_addr;
+ /*
+ * This is the host address where the response will be written when the
+ * request is complete. This area must be 16B aligned and must be
+ * cleared to zero before the request is made.
+ */
+ uint16_t fid;
+ /*
+ * Function ID of the function that is being configured. Only valid for
+ * a VF FID configured by the PF.
+ */
+ uint8_t unused_0;
+ uint8_t unused_1;
+ uint32_t num_vlan_entries;
+ /* Number of VLAN entries in the vlan_tag_mask_tbl. */
+ uint64_t vlan_tag_mask_tbl_addr;
+ /*
+ * The vlan_tag_mask_tbl_addr is the DMA address of the VLAN antispoof
+ * table. Each table entry contains the 16-bit TPID (0x8100 or 0x88a8
+ * only), 16-bit VLAN ID, and a 16-bit mask, all in network order to
+ * match hwrm_cfa_l2_set_rx_mask. For an individual VLAN entry, the mask
+ * value should be 0xfff for the 12-bit VLAN ID.
+ */
+};
+
+/* Output (16 bytes) */
+struct hwrm_cfa_vlan_antispoof_cfg_output {
+ uint16_t error_code;
+ /*
+ * Pass/Fail or error type Note: receiver to verify the in parameters,
+ * and fail the call with an error when appropriate
+ */
+ uint16_t req_type;
+ /* This field returns the type of original request. */
+ uint16_t seq_id;
+ /* This field provides original sequence number of the command. */
+ uint16_t resp_len;
+ /*
+ * This field is the length of the response in bytes. The last byte of
+ * the response is a valid flag that will read as '1' when the command
+ * has been completely written to memory.
+ */
+ uint32_t unused_0;
+ uint8_t unused_1;
+ uint8_t unused_2;
+ uint8_t unused_3;
+ uint8_t valid;
+ /*
+ * This field is used in Output records to indicate that the output is
+ * completely written to RAM. This field should be read as '1' to
+ * indicate that the output has been completely written. When writing a
+ * command completion or response to an internal processor, the order of
+ * writes has to be such that this field is written last.
+ */
+};
+
/* hwrm_tunnel_dst_port_query */
/*
* Description: This function is called by a driver to query tunnel type
diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_bnxt.c
index ec5855d..c1876f8 100644
--- a/drivers/net/bnxt/rte_pmd_bnxt.c
+++ b/drivers/net/bnxt/rte_pmd_bnxt.c
@@ -299,8 +299,6 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
struct rte_eth_dev *dev;
struct bnxt *bp;
int rc;
- int dflt_vnic;
- struct bnxt_vnic_info vnic;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
@@ -327,25 +325,11 @@ int rte_pmd_bnxt_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
if (!rc) {
bp->pf.vf_info[vf].vlan_spoof_en = on;
if (on) {
- dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf);
- if (dflt_vnic < 0) {
- /*
- * This simply indicates there's no driver
- * loaded. This is not an error.
- */
- RTE_LOG(INFO, PMD,
- "Unable to get default VNIC for VF %d\n",
- vf);
- } else {
- vnic.fw_vnic_id = dflt_vnic;
- if (bnxt_hwrm_vnic_qcfg(bp,
- &vnic, bp->pf.first_vf_id + vf) == 0) {
- if (bnxt_hwrm_cfa_l2_set_rx_mask(bp,
- &vnic, bp->pf.vf_info[vf].vlan_count,
- bp->pf.vf_info[vf].vlan_table))
- rc = -1;
- }
- }
+ if (bnxt_hwrm_cfa_vlan_antispoof_cfg(bp,
+ bp->pf.first_vf_id + vf,
+ bp->pf.vf_info[vf].vlan_count,
+ bp->pf.vf_info[vf].vlan_as_table))
+ rc = -1;
}
} else {
RTE_LOG(ERR, PMD, "Failed to update VF VNIC %d.\n", vf);
@@ -451,10 +435,49 @@ int rte_pmd_bnxt_set_vf_rxmode(uint8_t port, uint16_t vf,
return rc;
}
+static int bnxt_set_vf_table(struct bnxt *bp, uint16_t vf)
+{
+ int rc = 0;
+ int dflt_vnic;
+ struct bnxt_vnic_info vnic;
+
+ if (!BNXT_PF(bp)) {
+ RTE_LOG(ERR, PMD,
+ "Attempt to set VLAN table on non-PF port!\n");
+ return -EINVAL;
+ }
+
+ if (vf >= bp->pdev->max_vfs)
+ return -EINVAL;
+
+ dflt_vnic = bnxt_hwrm_func_qcfg_vf_dflt_vnic_id(bp, vf);
+ if (dflt_vnic < 0) {
+ /* This simply indicates there's no driver loaded.
+ * This is not an error.
+ */
+ RTE_LOG(ERR, PMD, "Unable to get default VNIC for VF %d\n", vf);
+ } else {
+ memset(&vnic, 0, sizeof(vnic));
+ vnic.fw_vnic_id = dflt_vnic;
+ if (bnxt_hwrm_vnic_qcfg(bp, &vnic,
+ bp->pf.first_vf_id + vf) == 0) {
+ if (bnxt_hwrm_cfa_l2_set_rx_mask(bp, &vnic,
+ bp->pf.vf_info[vf].vlan_count,
+ bp->pf.vf_info[vf].vlan_table))
+ rc = -1;
+ } else {
+ rc = -1;
+ }
+ }
+
+ return rc;
+}
+
int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
uint64_t vf_mask, uint8_t vlan_on)
{
struct bnxt_vlan_table_entry *ve;
+ struct bnxt_vlan_antispoof_table_entry *vase;
struct rte_eth_dev *dev;
struct bnxt *bp;
uint16_t cnt;
@@ -480,6 +503,10 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
rc = -1;
continue;
}
+ if (bp->pf.vf_info[i].vlan_as_table == NULL) {
+ rc = -1;
+ continue;
+ }
if (vlan_on) {
/* First, search for a duplicate... */
for (j = 0; j < cnt; j++) {
@@ -489,13 +516,13 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
}
if (j == cnt) {
/* Now check that there's space */
- if (cnt == getpagesize() /
- sizeof(struct bnxt_vlan_table_entry)) {
+ if (cnt == getpagesize() / sizeof(struct
+ bnxt_vlan_antispoof_table_entry)) {
RTE_LOG(ERR, PMD,
- "VF %d VLAN table is full\n",
- i);
+ "VLAN anti-spoof table is full\n");
RTE_LOG(ERR, PMD,
- "cannot add VLAN %u\n", vlan);
+ "VF %d cannot add VLAN %u\n",
+ i, vlan);
rc = -1;
continue;
}
@@ -506,6 +533,11 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
* And finally, add to the
* end of the table
*/
+ vase = &bp->pf.vf_info[i].vlan_as_table[cnt];
+ // TODO: Hardcoded TPID
+ vase->tpid = rte_cpu_to_be_16(0x8100);
+ vase->vid = rte_cpu_to_be_16(vlan);
+ vase->mask = rte_cpu_to_be_16(0xfff);
ve = &bp->pf.vf_info[i].vlan_table[cnt];
/* TODO: Hardcoded TPID */
ve->tpid = rte_cpu_to_be_16(0x8100);
@@ -520,12 +552,15 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port, uint16_t vlan,
&bp->pf.vf_info[i].vlan_table[j + 1],
getpagesize() - ((j + 1) *
sizeof(struct bnxt_vlan_table_entry)));
+ memmove(&bp->pf.vf_info[i].vlan_as_table[j],
+ &bp->pf.vf_info[i].vlan_as_table[j + 1],
+ getpagesize() - ((j + 1) * sizeof(struct
+ bnxt_vlan_antispoof_table_entry)));
j--;
cnt = --bp->pf.vf_info[i].vlan_count;
}
}
- rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id, i,
- bp->pf.vf_info[i].vlan_spoof_en);
+ bnxt_set_vf_table(bp, i);
}
return rc;
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 7/8] net/bnxt: check invalid l2_filter_id
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (5 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
2017-07-21 9:31 ` [dpdk-dev] [PATCH v2 0/8] bnxt patchset Ferruh Yigit
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
Add code to check for invalid filter_id in bnxt_hwrm_clear_filter
Fixes: f92735db1e4c ("net/bnxt: add L2 filter alloc/init/free")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index a82cc81..e230b46 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -327,6 +327,9 @@ int bnxt_hwrm_clear_filter(struct bnxt *bp,
struct hwrm_cfa_l2_filter_free_input req = {.req_type = 0 };
struct hwrm_cfa_l2_filter_free_output *resp = bp->hwrm_cmd_resp_addr;
+ if (filter->fw_l2_filter_id == UINT64_MAX)
+ return 0;
+
HWRM_PREP(req, CFA_L2_FILTER_FREE, -1, resp);
req.l2_filter_id = rte_cpu_to_le_64(filter->fw_l2_filter_id);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [dpdk-dev] [PATCH v2 8/8] net/bnxt: fix to free a filter before reusing it
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (6 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
@ 2017-07-21 3:22 ` Ajit Khaparde
2017-07-21 9:31 ` [dpdk-dev] [PATCH v2 0/8] bnxt patchset Ferruh Yigit
8 siblings, 0 replies; 22+ messages in thread
From: Ajit Khaparde @ 2017-07-21 3:22 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit
This patch sends the HWRM command to free a filter in the hardware,
before using it again.
Fixes: f92735db1e4c ("net/bnxt: add L2 filter alloc/init/free")
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_hwrm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index e230b46..4b1810c 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -352,6 +352,9 @@ int bnxt_hwrm_set_filter(struct bnxt *bp,
struct hwrm_cfa_l2_filter_alloc_output *resp = bp->hwrm_cmd_resp_addr;
uint32_t enables = 0;
+ if (filter->fw_l2_filter_id != UINT64_MAX)
+ bnxt_hwrm_clear_filter(bp, filter);
+
HWRM_PREP(req, CFA_L2_FILTER_ALLOC, -1, resp);
req.flags = rte_cpu_to_le_32(filter->flags);
--
2.10.1 (Apple Git-78)
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [dpdk-dev] [PATCH v2 0/8] bnxt patchset
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
` (7 preceding siblings ...)
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
@ 2017-07-21 9:31 ` Ferruh Yigit
8 siblings, 0 replies; 22+ messages in thread
From: Ferruh Yigit @ 2017-07-21 9:31 UTC (permalink / raw)
To: Ajit Khaparde, dev
On 7/21/2017 4:22 AM, Ajit Khaparde wrote:
> This patch set fixes some of the issues found during testing.
> Please apply.
>
> v1->v2: incorporate review feedback
>
> net/bnxt: fix log levels for non error conditions.
> net/bnxt: fix to avoid a segfault
> net/bnxt: fix vnic cleanup
> net/bnxt: fix set link config
> net/bnxt: reset VF stats during initialization
> net/bnxt: fix VLAN antispoof configuration code
> net/bnxt: check invalid l2_filter_id
> net/bnxt: fix to free a filter before reusing it
Series applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
@ 2017-07-21 19:09 ` Stephen Hurd
0 siblings, 0 replies; 22+ messages in thread
From: Stephen Hurd @ 2017-07-21 19:09 UTC (permalink / raw)
To: Ajit Khaparde; +Cc: dev, Ferruh Yigit
So the only change was replacing a nesting level with a continue? Yeah,
looks good.
On Thu, Jul 20, 2017 at 8:22 PM, Ajit Khaparde <ajit.khaparde@broadcom.com>
wrote:
> Fix use of local variable to avoid segfault.
> cnt was incorrectly tested and decremented in the loop that removes
> a VLAN from the table.
>
> Fixes: 36735a932ca7 ("support set VF QOS and MAC anti spoof")
>
> Signed-off-by: Stephen Hurd <stephen.hurd@broadcom.com>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
>
> --
> v1->v2: incorporate review feedback.
> ---
> drivers/net/bnxt/rte_pmd_bnxt.c | 101 +++++++++++++++++++-----------
> ----------
> 1 file changed, 49 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/net/bnxt/rte_pmd_bnxt.c b/drivers/net/bnxt/rte_pmd_
> bnxt.c
> index 0a8fb1e..ec5855d 100644
> --- a/drivers/net/bnxt/rte_pmd_bnxt.c
> +++ b/drivers/net/bnxt/rte_pmd_bnxt.c
> @@ -473,62 +473,59 @@ int rte_pmd_bnxt_set_vf_vlan_filter(uint8_t port,
> uint16_t vlan,
>
> for (i = 0; vf_mask; i++, vf_mask >>= 1) {
> cnt = bp->pf.vf_info[i].vlan_count;
> - if (vf_mask & 1) {
> - if (bp->pf.vf_info[i].vlan_table == NULL) {
> - rc = -1;
> - continue;
> + if ((vf_mask & 1) == 0)
> + continue;
> +
> + if (bp->pf.vf_info[i].vlan_table == NULL) {
> + rc = -1;
> + continue;
> + }
> + if (vlan_on) {
> + /* First, search for a duplicate... */
> + for (j = 0; j < cnt; j++) {
> + if (rte_be_to_cpu_16(
> + bp->pf.vf_info[i].vlan_table[j].vid)
> == vlan)
> + break;
> }
> - if (vlan_on) {
> - /* First, search for a duplicate... */
> - for (j = 0; j < cnt; j++) {
> - if (rte_be_to_cpu_16(
> - bp->pf.vf_info[i].vlan_table[j].vid)
> ==
> - vlan)
> - break;
> - }
> - if (j == cnt) {
> - /* Now check that there's space */
> - if (cnt == getpagesize() /
> - sizeof(struct
> bnxt_vlan_table_entry)) {
> - RTE_LOG(ERR, PMD,
> - "VF %d VLAN table is
> full\n",
> - i);
> - RTE_LOG(ERR, PMD,
> - "cannot add VLAN
> %u\n",
> - vlan);
> - rc = -1;
> - continue;
> - }
> -
> - cnt =
> bp->pf.vf_info[i].vlan_count++;
> - /*
> - * And finally, add to the
> - * end of the table
> - */
> - ve = &bp->pf.vf_info[i].vlan_table[
> cnt];
> - /* TODO: Hardcoded TPID */
> - ve->tpid =
> rte_cpu_to_be_16(0x8100);
> - ve->vid = rte_cpu_to_be_16(vlan);
> - }
> - } else {
> - for (j = 0; cnt; j++) {
> - if (rte_be_to_cpu_16(
> - bp->pf.vf_info[i].vlan_table[j].vid)
> !=
> - vlan)
> - continue;
> - memmove(
> - &bp->pf.vf_info[i].vlan_table[j],
> - &bp->pf.vf_info[i].vlan_table[j
> + 1],
> - getpagesize() -
> - ((j + 1) *
> - sizeof(struct
> bnxt_vlan_table_entry)));
> - j--;
> - cnt =
> bp->pf.vf_info[i].vlan_count--;
> + if (j == cnt) {
> + /* Now check that there's space */
> + if (cnt == getpagesize() /
> + sizeof(struct bnxt_vlan_table_entry)) {
> + RTE_LOG(ERR, PMD,
> + "VF %d VLAN table is
> full\n",
> + i);
> + RTE_LOG(ERR, PMD,
> + "cannot add VLAN %u\n",
> vlan);
> + rc = -1;
> + continue;
> }
> +
> + /* cnt is one less than vlan_count */
> + cnt = bp->pf.vf_info[i].vlan_count++;
> + /*
> + * And finally, add to the
> + * end of the table
> + */
> + ve = &bp->pf.vf_info[i].vlan_table[cnt];
> + /* TODO: Hardcoded TPID */
> + ve->tpid = rte_cpu_to_be_16(0x8100);
> + ve->vid = rte_cpu_to_be_16(vlan);
> + }
> + } else {
> + for (j = 0; j < cnt; j++) {
> + if (rte_be_to_cpu_16(
> + bp->pf.vf_info[i].vlan_table[j].vid)
> != vlan)
> + continue;
> + memmove(&bp->pf.vf_info[i].vlan_table[j],
> + &bp->pf.vf_info[i].vlan_table[j +
> 1],
> + getpagesize() - ((j + 1) *
> + sizeof(struct
> bnxt_vlan_table_entry)));
> + j--;
> + cnt = --bp->pf.vf_info[i].vlan_count;
> }
> - rte_pmd_bnxt_set_vf_vlan_anti_
> spoof(dev->data->port_id,
> - i, bp->pf.vf_info[i].vlan_spoof_
> en);
> }
> + rte_pmd_bnxt_set_vf_vlan_anti_spoof(dev->data->port_id, i,
> + bp->pf.vf_info[i].vlan_spoof_en);
> }
>
> return rc;
> --
> 2.10.1 (Apple Git-78)
>
>
--
Stephen Hurd
949-926-8039
stephen.hurd@broadcom.com
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2017-07-21 19:09 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-20 4:48 [dpdk-dev] [PATCH 0/8] bnxt patchset Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
2017-07-20 9:56 ` Ferruh Yigit
2017-07-20 4:48 ` [dpdk-dev] [PATCH 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 4/8] net/bnxt: fix set link config Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
2017-07-20 4:48 ` [dpdk-dev] [PATCH 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
2017-07-20 10:02 ` [dpdk-dev] [PATCH 0/8] bnxt patchset Ferruh Yigit
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 " Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 1/8] net/bnxt: fix log levels for non error conditions Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 2/8] net/bnxt: fix to avoid a segfault Ajit Khaparde
2017-07-21 19:09 ` Stephen Hurd
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 3/8] net/bnxt: fix vnic cleanup Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 4/8] net/bnxt: fix set link config Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 5/8] net/bnxt: reset VF stats during initialization Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 6/8] net/bnxt: fix VLAN antispoof configuration code Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 7/8] net/bnxt: check invalid l2_filter_id Ajit Khaparde
2017-07-21 3:22 ` [dpdk-dev] [PATCH v2 8/8] net/bnxt: fix to free a filter before reusing it Ajit Khaparde
2017-07-21 9:31 ` [dpdk-dev] [PATCH v2 0/8] bnxt patchset Ferruh Yigit
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).