From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/5] net/bnxt: check if MAC address is all zeros
Date: Sun, 21 Jan 2018 22:20:45 -0800 [thread overview]
Message-ID: <20180122062046.81908-5-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20180122062046.81908-1-ajit.khaparde@broadcom.com>
In certain cases the MAC address of a port could be all zeros.
Catch it early, log a message and fail the initiaization.
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 10 ++++++++++
drivers/net/bnxt/bnxt_filter.c | 2 +-
drivers/net/bnxt/bnxt_filter.h | 1 +
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index af4673dc2..ebc2dfab2 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3247,6 +3247,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
rc = -ENOMEM;
goto error_free;
}
+
+ if (check_zero_bytes(bp->dflt_mac_addr, ETHER_ADDR_LEN)) {
+ PMD_DRV_LOG(ERR,
+ "Invalid MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
+ bp->dflt_mac_addr[0], bp->dflt_mac_addr[1],
+ bp->dflt_mac_addr[2], bp->dflt_mac_addr[3],
+ bp->dflt_mac_addr[4], bp->dflt_mac_addr[5]);
+ rc = -EINVAL;
+ goto error_free;
+ }
/* Copy the permanent MAC from the qcap response address now. */
memcpy(bp->mac_addr, bp->dflt_mac_addr, sizeof(bp->mac_addr));
memcpy(ð_dev->data->mac_addrs[0], bp->mac_addr, ETHER_ADDR_LEN);
diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 0716dd8fd..032e8eed0 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -250,7 +250,7 @@ nxt_non_void_action(const struct rte_flow_action *cur)
}
}
-static inline int check_zero_bytes(const uint8_t *bytes, int len)
+int check_zero_bytes(const uint8_t *bytes, int len)
{
int i;
for (i = 0; i < len; i++)
diff --git a/drivers/net/bnxt/bnxt_filter.h b/drivers/net/bnxt/bnxt_filter.h
index 2591a87e2..a3c702df6 100644
--- a/drivers/net/bnxt/bnxt_filter.h
+++ b/drivers/net/bnxt/bnxt_filter.h
@@ -97,6 +97,7 @@ struct bnxt_filter_info *bnxt_get_unused_filter(struct bnxt *bp);
void bnxt_free_filter(struct bnxt *bp, struct bnxt_filter_info *filter);
struct bnxt_filter_info *bnxt_get_l2_filter(struct bnxt *bp,
struct bnxt_filter_info *nf, struct bnxt_vnic_info *vnic);
+int check_zero_bytes(const uint8_t *bytes, int len);
#define NTUPLE_FLTR_ALLOC_INPUT_EN_SRC_MACADDR \
HWRM_CFA_NTUPLE_FILTER_ALLOC_INPUT_ENABLES_SRC_MACADDR
--
2.14.3 (Apple Git-98)
next prev parent reply other threads:[~2018-01-22 6:20 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 6:20 [dpdk-dev] [PATCH 0/5] bnxt patchset Ajit Khaparde
2018-01-22 6:20 ` [dpdk-dev] [PATCH 1/5] net/bnxt: fix size of tx ring in HW Ajit Khaparde
2018-01-22 12:22 ` Ferruh Yigit
2018-01-22 6:20 ` [dpdk-dev] [PATCH 2/5] net/bnxt: use driver specific dynamic log type Ajit Khaparde
2018-01-22 12:23 ` Ferruh Yigit
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 0/7] bnxt patchset Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 1/7] net/bnxt: fix size of tx ring in HW Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 2/7] net/bnxt: use driver specific dynamic log type Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 3/7] net/bnxt: register for more async events Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 4/7] net/bnxt: check if MAC address is all zeros Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 5/7] net/bnxt: support for rx/tx_queue_start/stop ops Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 6/7] net/bnxt: add 100G speed detection Ajit Khaparde
2018-01-26 17:08 ` Ferruh Yigit
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 0/7] bnxt patchset Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 1/7] net/bnxt: fix size of tx ring in HW Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 2/7] net/bnxt: use driver specific dynamic log type Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 3/7] net/bnxt: register for more async events Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 4/7] net/bnxt: check if MAC address is all zeros Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 5/7] net/bnxt: support for rx/tx_queue_start/stop ops Ajit Khaparde
2018-01-26 17:31 ` [dpdk-dev] [PATCH v3 6/7] net/bnxt: add 100G speed detection Ajit Khaparde
2018-01-26 17:32 ` [dpdk-dev] [PATCH v3 7/7] net/bnxt: fix number of pools for RSS Ajit Khaparde
2018-01-26 18:00 ` [dpdk-dev] [PATCH v3 0/7] bnxt patchset Ferruh Yigit
2018-01-26 17:33 ` [dpdk-dev] [PATCH v2 6/7] net/bnxt: add 100G speed detection Ajit Khaparde
2018-01-25 22:47 ` [dpdk-dev] [PATCH v2 7/7] net/bnxt: fix number of pools for RSS Ajit Khaparde
2018-01-26 17:35 ` [dpdk-dev] [PATCH v2 0/7] bnxt patchset Ferruh Yigit
2018-01-26 17:37 ` Ferruh Yigit
2018-01-22 6:20 ` [dpdk-dev] [PATCH 3/5] net/bnxt: register for more async events Ajit Khaparde
2018-01-22 6:20 ` Ajit Khaparde [this message]
2018-01-22 12:26 ` [dpdk-dev] [PATCH 4/5] net/bnxt: check if MAC address is all zeros Ferruh Yigit
2018-01-22 6:20 ` [dpdk-dev] [PATCH 5/5] net/bnxt: Support for rx/tx_queue_start/stop ops Ajit Khaparde
2018-01-22 12:25 ` Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180122062046.81908-5-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).