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 E082E460C1; Mon, 20 Jan 2025 10:44:00 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A81D740A4B; Mon, 20 Jan 2025 10:43:50 +0100 (CET) Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by mails.dpdk.org (Postfix) with ESMTP id B5BAD40A4B for ; Mon, 20 Jan 2025 10:43:48 +0100 (CET) X-QQ-mid: bizesmtp86t1737366222twb7cpus X-QQ-Originating-IP: IctDG4IAvuw0Y09Sf57p89lEc4hoSHjKIzkDWoNTLzI= Received: from DSK-zaiyuwang.trustnetic.com ( [115.197.136.137]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 20 Jan 2025 17:43:41 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 1791874550503625789 From: Zaiyu Wang To: dev@dpdk.org Cc: Zaiyu Wang , Jiawen Wu Subject: [PATCH v4 04/15] net/ngbe: add promiscuous and allmulticast ops for VF device Date: Mon, 20 Jan 2025 17:42:30 +0800 Message-Id: <20250120094242.1844-5-zaiyuwang@trustnetic.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20250120094242.1844-1-zaiyuwang@trustnetic.com> References: <20250109040227.1016-1-zaiyuwang@trustnetic.com> <20250120094242.1844-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: NafziRg7Bx69WESPibfkB5gwVoy7OVZIVF15YymGHxES3VZvs7cM3kYp jdyUlRCVLd+SGDU9qdl7eISfkee/pE/thTcqwmxnsAfsAZ/aau5DJIEUTDCgHAqLQ6MziX3 4vEMbpqS+hslB+FwqLLbm2M1EoadBysUtpX97u5BFb1xSWKqLDMy3OZMmF/3fGrFwO9mOO4 v/4hnzgv8yTeTlL7qdX5Onim9pcnxE5G2vddl4tb3WKB3JwzlYPTHVdVxEITpKU3D0BI4oJ m+izD7M4YbaeIJ/k2YcN54gVkSqEbp8zEAtHC8m7xrKAsIpiqS2A7HHR+X0XPXy9ev/opGN 4kOTUpJGC0+X01Hx0qXoE7qPp5wMxKCZSqQ+s0eEFAKL8knukxAdt6lIuZHVAHp/diEoALs +ue229uA8Ebanr+RESFhzPFcTl92m0FJw/XCqiuYf0pc30K+WkCwKFU92R/4yW1dsz2mFx4 GHOTTzDJD4spcL/SM/EC9JJwio6kKXWSTZ1vsc40sL0AONW2vqxkrgC4QdgBQvHqmjlpDi9 hGRoudUEaRBxTShL/RWFbB5tM4yueF8TABhtFAIk/7NDY8ZoqluQwVZzQrHKtiOtbGrWR0a 9g1DbQph4dOdUfB2U34vLP2Zqr/QxaBx2Hp7c5CQ9Q8RWR22kburJkBsuBGFeJSqHfE3HaM 5XSURQcG3wKjgXE2X0QQr7srhlUIh/aegtaKAGWKAxQzCTGdL4q+06J2q6jtvKvZyz5UMMn w2p+RnG6WDW8X0uKtOqDktTUxzVLrURGOwmN86pZOJnisNb1TA+gdJU+cEs3S14yDw5JMQb vz92ceKAoVcA3PK7BeZU5Il669WQoa+T4vyuPWTi6IxuY8XjQ+/3jFApYBt51CMSqsw0NyN oiNjVCs3C//VNWlwdlGDVh30g1TuSk4OgBCjFIKEwPRU8etMXfIN59U2VpNvqu1zHCOOWQ2 1Yj5hR3EsQ60fmwnCj/KbX2V9VPApONpj4u1/dJxYAgyI7RM4SDkWqgk7wCr2jISyfzadhg 6rp2kVuY1oScALuq0Z X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= 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 53824a7c90..ba12357255 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