From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D852A46027; Thu, 9 Jan 2025 05:03:52 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7906840B8D; Thu, 9 Jan 2025 05:03:39 +0100 (CET) Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) by mails.dpdk.org (Postfix) with ESMTP id E1ED340655 for ; Thu, 9 Jan 2025 05:03:37 +0100 (CET) X-QQ-mid: bizesmtp84t1736395413t564z950 X-QQ-Originating-IP: in9gy9vSRSVJ02RG4d5poOIY3YvqFHI0gpEoZG6P/DE= Received: from DSK-zaiyuwang.trustnetic.com ( [218.72.126.41]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 09 Jan 2025 12:03:31 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6602350914279991487 From: Zaiyu Wang To: dev@dpdk.org Cc: Zaiyu Wang , Jiawen Wu Subject: [PATCH 04/15] net/ngbe: add promiscuous and allmulticast ops for VF device Date: Thu, 9 Jan 2025 12:02:14 +0800 Message-Id: <20250109040227.1016-5-zaiyuwang@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20250109040227.1016-1-zaiyuwang@trustnetic.com> References: <20250109040227.1016-1-zaiyuwang@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybglogicsvrgz:qybglogicsvrgz5a-1 X-QQ-XMAILINFO: N5WcfomXm5JbShfI9lt5cbsMtL3t32xHl04CG1fK6s3mvnorWvDWjWMR 77Fv6HxMgZoN+r8rfGAUMsnMhBjugDXeeC+hAFFE7UAEu3NIg9rcvl/oM8i8SeXGWzQtqNf eIUDzOwVIHplqRvF3dRgz53DvsV1b7x+IRCU7JZ00haGhTuFutEGFjcmq0jyVFk5WySoxEH reBTsVoSSfk0mJvHVEWlXemmnh6lnsKyfNbmadVqqsZfyGLkuzlXk6ej9PrBW6XyMNwo7Ks P5ZIyahNg6KgeFXf2UVrAqqb3IhtLB6q9ziZKsxujn1sTMsa2/zlJsPSGsLQP0pl/xb0cT4 TIxIHAuBMDlfrz09elHoa2MIyC7CcyCNqSqLV8v6eHXfqWJ4L8OUNulhwTvpiIjuVELkrqh NDEwjrvOcQbhRkC6SyDzp3TR8QCsEz0ZC1FQLoT3Ct9HwzgvBUjaw4CAPKhA9Fl4cFxZsri vvYSshQS0j+7E4ZPdq9hC+GlVXvqvuHHbA+21MYML7Kq3uD9Wxt8Otf8+QKx91Tv1VYrTPX 6RvBxcN+/+KrPfFRpRXuFOO5nztI55NkuQAzjKt9jI5omYVHcp2ucR5LrMw8qPHpuB33223 EgJC/vU2mIACXuyg/cRU8ByYE/BK7Y0ax6FzdJKScLVq7YmEHIiCBNWIlKzmUyTmUak82fm uJfbjKzMILphOqPf/NoNJJwKE6i3wCo/hqTyHj48G9VaSNy0CU4HLDNDoIFdyJopRN7WKIg Ec0Tz757mSFup4rhno44gZOhBwlXATK3Ps9BEGft0R4X08WMetuvI0vLr2a0wSDytdECFOH H0VxZIXLLAc9aAuO8KrLMfYPzpxfz3qtG2rMlR8J95cpNZWGVYRIHuDNMGXy1Rexoj6EZdi a9Ogtyt0t0WtFXPBJ/Aez13VCSXhuHTdoL6LKeRN+Z4bpHU1T6qpQMpar36eApEiJq0V5D5 9313PoTWK9YgkqykoGWFZ2yL7FFsTkD26CXFbJi1WpDHZCrhs7DdsQDeeey7afh2sML97Pa o210Trzw== X-QQ-XMRINFO: NyFYKkN4Ny6FSmKK/uo/jdU= X-QQ-RECHKSPAM: 0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Support to enable and disable promiscuous and allmulticast mode on VF device. Signed-off-by: Zaiyu Wang --- 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 b3d86e65ae..aa628dfa97 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 41684a2e50..918df6f0dc 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 275f682c05..d8ece38b00 100644 --- a/drivers/net/ngbe/ngbe_ethdev_vf.c +++ b/drivers/net/ngbe/ngbe_ethdev_vf.c @@ -20,6 +20,8 @@ static int ngbevf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); 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) @@ -158,6 +160,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"); @@ -267,11 +272,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