From: Zaiyu Wang <zaiyuwang@trustnetic.com>
To: dev@dpdk.org
Cc: Zaiyu Wang <zaiyuwang@trustnetic.com>,
Jiawen Wu <jiawenwu@trustnetic.com>
Subject: [PATCH v3 04/15] net/ngbe: add promiscuous and allmulticast ops for VF device
Date: Fri, 17 Jan 2025 19:44:42 +0800 [thread overview]
Message-ID: <20250117114455.15864-5-zaiyuwang@trustnetic.com> (raw)
In-Reply-To: <20250117114455.15864-1-zaiyuwang@trustnetic.com>
Support to enable and disable promiscuous and allmulticast mode on VF
device.
Signed-off-by: Zaiyu Wang <zaiyuwang@trustnetic.com>
---
doc/guides/nics/features/ngbe_vf.ini | 2 +
drivers/net/ngbe/base/ngbe_type.h | 1 +
drivers/net/ngbe/base/ngbe_vf.c | 39 +++++++++++
drivers/net/ngbe/base/ngbe_vf.h | 1 +
drivers/net/ngbe/ngbe_ethdev_vf.c | 96 ++++++++++++++++++++++++++++
5 files changed, 139 insertions(+)
diff --git a/doc/guides/nics/features/ngbe_vf.ini b/doc/guides/nics/features/ngbe_vf.ini
index 4335efb812..f8928c5a6c 100644
--- a/doc/guides/nics/features/ngbe_vf.ini
+++ b/doc/guides/nics/features/ngbe_vf.ini
@@ -4,6 +4,8 @@
; Refer to default.ini for the full list of available PMD features.
;
[Features]
+Promiscuous mode = Y
+Allmulticast mode = Y
CRC offload = P
VLAN offload = P
QinQ offload = P
diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h
index 4fd7080847..29dcd5f912 100644
--- a/drivers/net/ngbe/base/ngbe_type.h
+++ b/drivers/net/ngbe/base/ngbe_type.h
@@ -351,6 +351,7 @@ struct ngbe_mac_info {
void (*set_mac_anti_spoofing)(struct ngbe_hw *hw, bool enable, int vf);
void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
bool enable, int vf);
+ s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
/* Flow Control */
s32 (*fc_enable)(struct ngbe_hw *hw);
diff --git a/drivers/net/ngbe/base/ngbe_vf.c b/drivers/net/ngbe/base/ngbe_vf.c
index 7c8b082f97..ccf7148b9c 100644
--- a/drivers/net/ngbe/base/ngbe_vf.c
+++ b/drivers/net/ngbe/base/ngbe_vf.c
@@ -191,6 +191,43 @@ STATIC s32 ngbevf_write_msg_read_ack(struct ngbe_hw *hw, u32 *msg,
return mbx->read_posted(hw, retmsg, size, 0);
}
+/**
+ * ngbevf_update_xcast_mode - Update Multicast mode
+ * @hw: pointer to the HW structure
+ * @xcast_mode: new multicast mode
+ *
+ * Updates the Multicast Mode of VF.
+ **/
+s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
+{
+ u32 msgbuf[2];
+ s32 err;
+
+ switch (hw->api_version) {
+ case ngbe_mbox_api_12:
+ /* New modes were introduced in 1.3 version */
+ if (xcast_mode > NGBEVF_XCAST_MODE_ALLMULTI)
+ return NGBE_ERR_FEATURE_NOT_SUPPORTED;
+ /* Fall through */
+ case ngbe_mbox_api_13:
+ break;
+ default:
+ return NGBE_ERR_FEATURE_NOT_SUPPORTED;
+ }
+
+ msgbuf[0] = NGBE_VF_UPDATE_XCAST_MODE;
+ msgbuf[1] = xcast_mode;
+
+ err = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+ if (err)
+ return err;
+
+ msgbuf[0] &= ~NGBE_VT_MSGTYPE_CTS;
+ if (msgbuf[0] == (NGBE_VF_UPDATE_XCAST_MODE | NGBE_VT_MSGTYPE_NACK))
+ return NGBE_ERR_FEATURE_NOT_SUPPORTED;
+ return 0;
+}
+
/**
* ngbevf_negotiate_api_version - Negotiate supported API version
* @hw: pointer to the HW structure
@@ -301,6 +338,8 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
mac->stop_hw = ngbe_stop_hw_vf;
mac->negotiate_api_version = ngbevf_negotiate_api_version;
+ mac->update_xcast_mode = ngbevf_update_xcast_mode;
+
mac->max_tx_queues = 1;
mac->max_rx_queues = 1;
diff --git a/drivers/net/ngbe/base/ngbe_vf.h b/drivers/net/ngbe/base/ngbe_vf.h
index da846dda45..79891e8389 100644
--- a/drivers/net/ngbe/base/ngbe_vf.h
+++ b/drivers/net/ngbe/base/ngbe_vf.h
@@ -16,6 +16,7 @@ s32 ngbe_init_hw_vf(struct ngbe_hw *hw);
s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
s32 ngbe_reset_hw_vf(struct ngbe_hw *hw);
s32 ngbe_stop_hw_vf(struct ngbe_hw *hw);
+s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
unsigned int *default_tc);
diff --git a/drivers/net/ngbe/ngbe_ethdev_vf.c b/drivers/net/ngbe/ngbe_ethdev_vf.c
index ed8400f6ed..28000471b5 100644
--- a/drivers/net/ngbe/ngbe_ethdev_vf.c
+++ b/drivers/net/ngbe/ngbe_ethdev_vf.c
@@ -18,6 +18,8 @@
#define NGBEVF_PMD_NAME "rte_ngbevf_pmd" /* PMD name */
static int ngbevf_dev_close(struct rte_eth_dev *dev);
+static int ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev);
+static int ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev);
/*
* The set of PCI devices this driver supports (for VF)
@@ -155,6 +157,9 @@ eth_ngbevf_dev_init(struct rte_eth_dev *eth_dev)
return -EIO;
}
+ /* enter promiscuous mode */
+ ngbevf_dev_promiscuous_enable(eth_dev);
+
PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
eth_dev->data->port_id, pci_dev->id.vendor_id,
pci_dev->id.device_id, "ngbe_mac_sp_vf");
@@ -264,11 +269,102 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
return 0;
}
+static int
+ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
+{
+ struct ngbe_hw *hw = ngbe_dev_hw(dev);
+ int ret;
+
+ switch (hw->mac.update_xcast_mode(hw, NGBEVF_XCAST_MODE_PROMISC)) {
+ case 0:
+ ret = 0;
+ break;
+ case NGBE_ERR_FEATURE_NOT_SUPPORTED:
+ ret = -ENOTSUP;
+ break;
+ default:
+ ret = -EAGAIN;
+ break;
+ }
+
+ return ret;
+}
+
+static int
+ngbevf_dev_promiscuous_disable(struct rte_eth_dev *dev)
+{
+ struct ngbe_hw *hw = ngbe_dev_hw(dev);
+ int ret;
+
+ switch (hw->mac.update_xcast_mode(hw, NGBEVF_XCAST_MODE_NONE)) {
+ case 0:
+ ret = 0;
+ break;
+ case NGBE_ERR_FEATURE_NOT_SUPPORTED:
+ ret = -ENOTSUP;
+ break;
+ default:
+ ret = -EAGAIN;
+ break;
+ }
+
+ return ret;
+}
+
+static int
+ngbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
+{
+ struct ngbe_hw *hw = ngbe_dev_hw(dev);
+ int ret;
+
+ if (dev->data->promiscuous == 1)
+ return 0;
+
+ switch (hw->mac.update_xcast_mode(hw, NGBEVF_XCAST_MODE_ALLMULTI)) {
+ case 0:
+ ret = 0;
+ break;
+ case NGBE_ERR_FEATURE_NOT_SUPPORTED:
+ ret = -ENOTSUP;
+ break;
+ default:
+ ret = -EAGAIN;
+ break;
+ }
+
+ return ret;
+}
+
+static int
+ngbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
+{
+ struct ngbe_hw *hw = ngbe_dev_hw(dev);
+ int ret;
+
+ switch (hw->mac.update_xcast_mode(hw, NGBEVF_XCAST_MODE_MULTI)) {
+ case 0:
+ ret = 0;
+ break;
+ case NGBE_ERR_FEATURE_NOT_SUPPORTED:
+ ret = -ENOTSUP;
+ break;
+ default:
+ ret = -EAGAIN;
+ break;
+ }
+
+ return ret;
+}
+
/*
* dev_ops for virtual function, bare necessities for basic vf
* operation have been implemented
*/
static const struct eth_dev_ops ngbevf_eth_dev_ops = {
+ .promiscuous_enable = ngbevf_dev_promiscuous_enable,
+ .promiscuous_disable = ngbevf_dev_promiscuous_disable,
+ .allmulticast_enable = ngbevf_dev_allmulticast_enable,
+ .allmulticast_disable = ngbevf_dev_allmulticast_disable,
.dev_infos_get = ngbevf_dev_info_get,
};
--
2.21.0.windows.1
next prev parent reply other threads:[~2025-01-17 11:46 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 4:02 [PATCH 00/15] net/ngbe: add VF driver support Zaiyu Wang
2025-01-09 4:02 ` [PATCH 01/15] net/ngbe: add ethdev probe and remove for VF device Zaiyu Wang
2025-01-09 4:02 ` [PATCH 02/15] net/ngbe: add support for PF-VF mailbox interface Zaiyu Wang
2025-01-09 4:02 ` [PATCH 03/15] net/ngbe: add hardware configuration code for VF device Zaiyu Wang
2025-01-09 4:02 ` [PATCH 04/15] net/ngbe: add promiscuous and allmulticast ops " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 05/15] net/ngbe: add set MTU " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 06/15] net/ngbe: add add/remove/set mac addr " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 07/15] net/ngbe: add datapath init code " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 08/15] net/ngbe: add vlan related ops " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 09/15] net/ngbe: add interrupt support " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 10/15] net/ngbe: add link update ops " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 11/15] net/ngbe: add stats and xstats " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 12/15] net/ngbe: add start/stop/reset/close " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 13/15] net/ngbe: add multicast MAC filter " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 14/15] net/ngbe: add dump registers " Zaiyu Wang
2025-01-09 4:02 ` [PATCH 15/15] net/ngbe: add some ops which PF has implemented Zaiyu Wang
2025-01-10 4:17 ` [PATCH 00/15] net/ngbe: add VF driver support Stephen Hemminger
2025-01-17 10:40 ` [PATCH v2 " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 01/15] net/ngbe: add ethdev probe and remove for VF device Zaiyu Wang
2025-01-17 16:51 ` Stephen Hemminger
2025-01-17 10:41 ` [PATCH v2 02/15] net/ngbe: add support for PF-VF mailbox interface Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 03/15] net/ngbe: add hardware configuration code for VF device Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 04/15] net/ngbe: add promiscuous and allmulticast ops " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 05/15] net/ngbe: add set MTU " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 06/15] net/ngbe: add add/remove/set mac addr " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 07/15] net/ngbe: add datapath init code " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 08/15] net/ngbe: add VLAN related ops " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 09/15] net/ngbe: add interrupt support " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 10/15] net/ngbe: add link update ops " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 11/15] net/ngbe: add stats and xstats " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 12/15] net/ngbe: add start/stop/reset/close " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 13/15] net/ngbe: add multicast MAC filter " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 14/15] net/ngbe: add dump registers " Zaiyu Wang
2025-01-17 10:41 ` [PATCH v2 15/15] net/ngbe: add some ops which PF has implemented Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 00/15] net/ngbe: add VF driver support Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 01/15] net/ngbe: add ethdev probe and remove for VF device Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 02/15] net/ngbe: add support for PF-VF mailbox interface Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 03/15] net/ngbe: add hardware configuration code for VF device Zaiyu Wang
2025-01-17 11:44 ` Zaiyu Wang [this message]
2025-01-17 11:44 ` [PATCH v3 05/15] net/ngbe: add set MTU ops " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 06/15] net/ngbe: add add/remove/set mac addr " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 07/15] net/ngbe: add datapath init code " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 08/15] net/ngbe: add VLAN related ops " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 09/15] net/ngbe: add interrupt support " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 10/15] net/ngbe: add link update ops " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 11/15] net/ngbe: add stats and xstats " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 12/15] net/ngbe: add start/stop/reset/close " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 13/15] net/ngbe: add multicast MAC filter " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 14/15] net/ngbe: add dump registers " Zaiyu Wang
2025-01-17 11:44 ` [PATCH v3 15/15] net/ngbe: add some ops which PF has implemented Zaiyu Wang
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=20250117114455.15864-5-zaiyuwang@trustnetic.com \
--to=zaiyuwang@trustnetic.com \
--cc=dev@dpdk.org \
--cc=jiawenwu@trustnetic.com \
/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).