Skip to contentSkip to conversation

net/ngbe: add VF driver support

PATCH Superseded Zaiyu Wang 2 participants 68 messages Jan 9, 2025 – Jan 21, 2025

Subsystems (2)
lore
Share & tools
lore

Zaiyu Wang

author
#0 lore raw

cover net/ngbe: add VF driver support

This patch adds support to VF device for ngbe PMD

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add vlan related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   38 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  669 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1351 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  210 ++++
 13 files changed, 2733 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
Signature · 1 line
2.21.0.windows.1
author
#1 lore raw

PATCH 1/15 net/ngbe: add ethdev probe and remove for VF device

Introduce virtual function driver in ngbe PMD, add simple init and uninit function to probe and remove the device.

With this single patch, app/dpdk-testpmd can launch/quit normally and recognize the VF device.

---
 doc/guides/nics/features/ngbe_vf.ini |  11 ++
 drivers/net/ngbe/base/meson.build    |   1 +
 drivers/net/ngbe/base/ngbe.h         |   1 +
 drivers/net/ngbe/base/ngbe_hw.c      |   4 +
 drivers/net/ngbe/base/ngbe_vf.c      |  26 +++++
 drivers/net/ngbe/base/ngbe_vf.h      |  13 +++
 drivers/net/ngbe/meson.build         |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 166 +++++++++++++++++++++++++++
 8 files changed, 223 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
doc/guides/nics/features/ngbe_vf.ini new file +11 -0
new file mode 100644
index 0000000000..26e2a331b1
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'txgbe_vf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file
drivers/net/ngbe/base/meson.build +1 -0
index 390b0f9c12..dd68100bf8 100644
@@ -10,6 +10,7 @@ sources = [
         'ngbe_phy_rtl.c',
         'ngbe_phy_mvl.c',
         'ngbe_phy_yt.c',
+        'ngbe_vf.c',
 ]
 
 error_cflags = []
drivers/net/ngbe/base/ngbe.h +1 -0
index 1d17c2f115..da20829c40 100644
@@ -11,5 +11,6 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_phy.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 #endif /* _NGBE_H_ */
drivers/net/ngbe/base/ngbe_hw.c +4 -0
index 29944f5070..e29a1946e5 100644
@@ -9,6 +9,7 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_mng.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 static s32 ngbe_is_lldp(struct ngbe_hw *hw)
 {
@@ -2113,6 +2114,9 @@ s32 ngbe_init_shared_code(struct ngbe_hw *hw)
 	case ngbe_mac_em:
 		ngbe_init_ops_pf(hw);
 		break;
+	case ngbe_mac_em_vf:
+		ngbe_init_ops_vf(hw);
+		break;
 	default:
 		status = NGBE_ERR_DEVICE_NOT_SUPPORTED;
 		break;
drivers/net/ngbe/base/ngbe_vf.c new file +26 -0
new file mode 100644
index 0000000000..4d3982b3c1
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2021 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#include "ngbe_type.h"
+#include "ngbe_vf.h"
+
+/**
+ *  ngbe_init_ops_vf - Initialize the pointers for vf
+ *  @hw: pointer to hardware structure
+ *
+ *  This will assign function pointers, adapter-specific functions can
+ *  override the assignment of generic function pointers by assigning
+ *  their own adapter-specific function pointers.
+ *  Does not touch the hardware.
+ **/
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mac_info *mac = &hw->mac;
+
+	mac->max_tx_queues = 1;
+	mac->max_rx_queues = 1;
+
+	return 0;
+}
drivers/net/ngbe/base/ngbe_vf.h new file +13 -0
new file mode 100644
index 0000000000..7982ea231e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _NGBE_VF_H_
+#define _NGBE_VF_H_
+
+#include "ngbe_type.h"
+
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+
+#endif /* __NGBE_VF_H__ */
drivers/net/ngbe/meson.build +1 -0
index 402cea1c13..f4f8f7ee79 100644
@@ -15,6 +15,7 @@ sources = files(
         'ngbe_ptypes.c',
         'ngbe_pf.c',
         'ngbe_rxtx.c',
+        'ngbe_ethdev_vf.c',
 )
 
 deps += ['hash']
drivers/net/ngbe/ngbe_ethdev_vf.c new file +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#2 lore raw

PATCH 2/15 net/ngbe: add support for PF-VF mailbox interface

In reply to Zaiyu Wang

Add basic code to serve the communication between VF and PF devices.

---
 drivers/net/ngbe/base/ngbe_mbx.c  | 338 ++++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_mbx.h  |  29 +++
 drivers/net/ngbe/base/ngbe_type.h |   7 +
 drivers/net/ngbe/base/ngbe_vf.c   |  56 +++++
 drivers/net/ngbe/base/ngbe_vf.h   |   1 +
 5 files changed, 431 insertions(+)
drivers/net/ngbe/base/ngbe_mbx.c +338 -0
index bc0adbb3ec..a96a4aced7 100644
@@ -109,6 +109,344 @@ s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id)
 	return ret_val;
 }
 
+/**
+ *  ngbe_poll_for_msg - Wait for message notification
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification
+ **/
+STATIC s32 ngbe_poll_for_msg(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_msg)
+		goto out;
+
+	while (countdown && mbx->check_for_msg(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox message timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_poll_for_ack - Wait for message acknowledgment
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message acknowledgment
+ **/
+STATIC s32 ngbe_poll_for_ack(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_ack)
+		goto out;
+
+	while (countdown && mbx->check_for_ack(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox ack timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_read_posted_mbx - Wait for message notification and receive message
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification and
+ *  copied it into the receive buffer.
+ **/
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (!mbx->read)
+		goto out;
+
+	ret_val = ngbe_poll_for_msg(hw, mbx_id);
+
+	/* if ack received read message, otherwise we timed out */
+	if (!ret_val)
+		ret_val = mbx->read(hw, msg, size, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_posted_mbx - Write a message to the mailbox, wait for ack
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer and
+ *  received an ack to that message within delay * timeout period
+ **/
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size,
+			   u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* exit if either we can't write or there isn't a defined timeout */
+	if (!mbx->write || !mbx->timeout)
+		goto out;
+
+	/* send msg */
+	ret_val = mbx->write(hw, msg, size, mbx_id);
+
+	/* if msg sent wait until we receive an ack */
+	if (!ret_val)
+		ret_val = ngbe_poll_for_ack(hw, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_v2p_mailbox - read v2p mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  This function is used to read the v2p mailbox without losing the read to
+ *  clear status bits.
+ **/
+STATIC u32 ngbe_read_v2p_mailbox(struct ngbe_hw *hw)
+{
+	u32 v2p_mailbox = rd32(hw, NGBE_VFMBCTL);
+
+	v2p_mailbox |= hw->mbx.v2p_mailbox;
+	hw->mbx.v2p_mailbox |= v2p_mailbox & NGBE_VFMBCTL_R2C_BITS;
+
+	return v2p_mailbox;
+}
+
+/**
+ *  ngbe_check_for_bit_vf - Determine if a status bit was set
+ *  @hw: pointer to the HW structure
+ *  @mask: bitmask for bits to be tested and cleared
+ *
+ *  This function is used to check for the read to clear bits within
+ *  the V2P mailbox.
+ **/
+STATIC s32 ngbe_check_for_bit_vf(struct ngbe_hw *hw, u32 mask)
+{
+	u32 v2p_mailbox = ngbe_read_v2p_mailbox(hw);
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (v2p_mailbox & mask)
+		ret_val = 0;
+
+	hw->mbx.v2p_mailbox &= ~mask;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_msg_vf - checks to see if the PF has sent mail
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFSTS)) {
+		ret_val = 0;
+		hw->mbx.stats.reqs++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_ack_vf - checks to see if the PF has ACK'd
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFACK)) {
+		ret_val = 0;
+		hw->mbx.stats.acks++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_rst_vf - checks to see if the PF has reset
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns true if the PF has set the reset done bit or else false
+ **/
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, (NGBE_VFMBCTL_RSTD |
+	    NGBE_VFMBCTL_RSTI))) {
+		ret_val = 0;
+		hw->mbx.stats.rsts++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_obtain_mbx_lock_vf - obtain mailbox lock
+ *  @hw: pointer to the HW structure
+ *
+ *  return SUCCESS if we obtained the mailbox lock
+ **/
+STATIC s32 ngbe_obtain_mbx_lock_vf(struct ngbe_hw *hw)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* Take ownership of the buffer */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_VFU);
+
+	/* reserve mailbox for vf use */
+	if (ngbe_read_v2p_mailbox(hw) & NGBE_VFMBCTL_VFU)
+		ret_val = 0;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_mbx_vf - Write a message to the mailbox
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer
+ **/
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			      u16 mbx_id)
+{
+	s32 ret_val;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_write;
+
+	/* flush msg and acks as we are overwriting the message buffer */
+	ngbe_check_for_msg_vf(hw, 0);
+	ngbe_check_for_ack_vf(hw, 0);
+
+	/* copy the caller specified message to the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		wr32a(hw, NGBE_VFMBX, i, msg[i]);
+
+	/* update stats */
+	hw->mbx.stats.msgs_tx++;
+
+	/* Drop VFU and interrupt the PF to tell it a message has been sent */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_REQ);
+
+out_no_write:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_mbx_vf - Reads a message from the inbox intended for vf
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to read
+ *
+ *  returns SUCCESS if it successfully read message from buffer
+ **/
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			     u16 mbx_id)
+{
+	s32 ret_val = 0;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_read;
+
+	/* copy the message from the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		msg[i] = rd32a(hw, NGBE_VFMBX, i);
+
+	/* Acknowledge receipt and release mailbox, then we're done */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_ACK);
+
+	/* update stats */
+	hw->mbx.stats.msgs_rx++;
+
+out_no_read:
+	return ret_val;
+}
+
+/**
+ *  ngbe_init_mbx_params_vf - set initial values for vf mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  Initializes the hw->mbx struct to correct values for vf mailbox
+ */
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+
+	/* start mailbox as timed out and let the reset_hw call set the timeout
+	 * value to begin communications
+	 */
+	mbx->timeout = 0;
+	mbx->usec_delay = NGBE_VF_MBX_INIT_DELAY;
+
+	mbx->size = NGBE_P2VMBX_SIZE;
+
+	mbx->stats.msgs_tx = 0;
+	mbx->stats.msgs_rx = 0;
+	mbx->stats.reqs = 0;
+	mbx->stats.acks = 0;
+	mbx->stats.rsts = 0;
+}
+
 STATIC s32 ngbe_check_for_bit_pf(struct ngbe_hw *hw, u32 mask)
 {
 	u32 mbvficr = rd32(hw, NGBE_MBVFICR);
drivers/net/ngbe/base/ngbe_mbx.h +29 -0
index d47da2718c..83561fd4cf 100644
@@ -73,11 +73,34 @@ enum ngbevf_xcast_modes {
 
 /* length of permanent address message returned from PF */
 #define NGBE_VF_PERMADDR_MSG_LEN	4
+/* word in permanent address message with the current multicast type */
+#define NGBE_VF_MC_TYPE_WORD		3
+
+#define NGBE_PF_CONTROL_MSG		0x0100 /* PF control message */
+
+/* mailbox API, version 2.0 VF requests */
+#define NGBE_VF_API_NEGOTIATE		0x08 /* negotiate API version */
+#define NGBE_VF_GET_QUEUES		0x09 /* get queue configuration */
+#define NGBE_VF_ENABLE_MACADDR		0x0A /* enable MAC address */
+#define NGBE_VF_DISABLE_MACADDR	0x0B /* disable MAC address */
+#define NGBE_VF_GET_MACADDRS		0x0C /* get all configured MAC addrs */
+#define NGBE_VF_SET_MCAST_PROMISC	0x0D /* enable multicast promiscuous */
+#define NGBE_VF_GET_MTU		0x0E /* get bounds on MTU */
+#define NGBE_VF_SET_MTU		0x0F /* set a specific MTU */
+
+/* mailbox API, version 2.0 PF requests */
+#define NGBE_PF_TRANSPARENT_VLAN	0x0101 /* enable transparent vlan */
+
+#define NGBE_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
+#define NGBE_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
 s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw);
 void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);
 
 s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
@@ -86,4 +109,10 @@ s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);
 
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id);
+
 #endif /* _NGBE_MBX_H_ */
drivers/net/ngbe/base/ngbe_type.h +7 -0
index a987bbe25b..35ebb7208a 100644
@@ -311,6 +311,7 @@ struct ngbe_mac_info {
 	s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
 	s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
 	void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
+	s32 (*negotiate_api_version)(struct ngbe_hw *hw, int api);
 
 	/* Link */
 	s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
@@ -422,6 +423,10 @@ struct ngbe_mbx_info {
 	void (*init_params)(struct ngbe_hw *hw);
 	s32  (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
 	s32  (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
+	s32  (*read_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
+	s32  (*write_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
 	s32  (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
@@ -429,6 +434,7 @@ struct ngbe_mbx_info {
 	struct ngbe_mbx_stats stats;
 	u32 timeout;
 	u32 usec_delay;
+	u32 v2p_mailbox;
 	u16 size;
 };
 
@@ -458,6 +464,7 @@ struct ngbe_hw {
 	u8 port_id;
 	u8 revision_id;
 	bool adapter_stopped;
+	int api_version;
 	bool wol_enabled;
 	bool ncsi_enabled;
 	bool lldp_enabled;
drivers/net/ngbe/base/ngbe_vf.c +56 -0

73 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 7982ea231e..23e5b0d8a3 100644
@@ -9,5 +9,6 @@
 #include "ngbe_type.h"
 
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 
 #endif /* __NGBE_VF_H__ */
Signature · 1 line
2.21.0.windows.1
author
#3 lore raw

PATCH 3/15 net/ngbe: add hardware configuration code for VF device

In reply to Zaiyu Wang

Add basic hardware configure flow and device information statement.

---
 doc/guides/nics/features/ngbe_vf.ini |   7 +
 drivers/net/ngbe/base/ngbe_mbx.h     |   2 +
 drivers/net/ngbe/base/ngbe_type.h    |   5 +
 drivers/net/ngbe/base/ngbe_vf.c      | 235 +++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   9 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 114 +++++++++++++
 6 files changed, 372 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +7 -0
index 26e2a331b1..b3d86e65ae 100644
@@ -4,6 +4,13 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+CRC offload          = P
+VLAN offload         = P
+QinQ offload         = P
+L3 checksum offload  = P
+L4 checksum offload  = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_mbx.h +2 -0
index 83561fd4cf..27e977737d 100644
@@ -57,6 +57,8 @@ enum ngbe_pfvf_api_rev {
 #define NGBE_VF_GET_RSS_KEY	0x0b    /* get RSS key */
 #define NGBE_VF_UPDATE_XCAST_MODE	0x0c
 
+#define NGBE_VF_BACKUP		0x8001 /* VF requests backup */
+
 /* mode choices for NGBE_VF_UPDATE_XCAST_MODE */
 enum ngbevf_xcast_modes {
 	NGBEVF_XCAST_MODE_NONE = 0,
drivers/net/ngbe/base/ngbe_type.h +5 -0
index 35ebb7208a..4fd7080847 100644
@@ -8,6 +8,9 @@
 
 #define NGBE_LINK_UP_TIME	90 /* 9.0 Seconds */
 
+#define NGBE_RX_HDR_SIZE	256
+#define NGBE_RX_BUF_SIZE	2048
+
 #define NGBE_FRAME_SIZE_MAX       (9728) /* Maximum frame size, +FCS */
 #define NGBE_FRAME_SIZE_DFT       (1518) /* Default frame size, +FCS */
 #define NGBE_NUM_POOL             (32)
@@ -17,6 +20,7 @@
 #define NGBE_MAX_QP               (8)
 #define NGBE_MAX_UTA              128
 
+#define NGBE_VF_INIT_TIMEOUT	200 /* Number of retries to clear RSTI */
 #define NGBE_PCI_MASTER_DISABLE_TIMEOUT	800
 #define NGBE_SPI_TIMEOUT	10000
 
@@ -480,6 +484,7 @@ struct ngbe_hw {
 	u32 q_tx_regs[8 * 4];
 	u32 gphy_efuse[2];
 	bool offset_loaded;
+	bool rx_loaded;
 	bool is_pf;
 	bool gpio_ctl;
 	bool lsc;
drivers/net/ngbe/base/ngbe_vf.c +235 -0

253 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +9 -0
index 23e5b0d8a3..da846dda45 100644
@@ -8,7 +8,16 @@
 
 #include "ngbe_type.h"
 
+#define NGBE_VF_MAX_TX_QUEUES	1
+#define NGBE_VF_MAX_RX_QUEUES	1
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+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);
 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);
 
 #endif /* __NGBE_VF_H__ */
drivers/net/ngbe/ngbe_ethdev_vf.c +114 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#4 lore raw

PATCH 4/15 net/ngbe: add promiscuous and allmulticast ops for VF device

In reply to Zaiyu Wang

Support to enable and disable promiscuous and allmulticast mode on VF device.

---
 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(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index b3d86e65ae..aa628dfa97 100644
@@ -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
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 4fd7080847..29dcd5f912 100644
@@ -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);
drivers/net/ngbe/base/ngbe_vf.c +39 -0
index 41684a2e50..918df6f0dc 100644
@@ -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;
 
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index da846dda45..79891e8389 100644
@@ -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);
drivers/net/ngbe/ngbe_ethdev_vf.c +96 -0

119 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#5 lore raw

PATCH 5/15 net/ngbe: add set MTU ops for VF device

In reply to Zaiyu Wang

Support to update MTU for VF device.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 24 +++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 36 ++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index aa628dfa97..333f02c854 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 29dcd5f912..f780b92efa 100644
@@ -352,6 +352,7 @@ struct ngbe_mac_info {
 	void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
 					bool enable, int vf);
 	s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
+	s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size);
 
 	/* Flow Control */
 	s32 (*fc_enable)(struct ngbe_hw *hw);
drivers/net/ngbe/base/ngbe_vf.c +24 -0
index 918df6f0dc..2d00d5998d 100644
@@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbevf_rlpml_set_vf - Set the maximum receive packet length
+ *  @hw: pointer to the HW structure
+ *  @max_size: value to assign to max frame size
+ **/
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size)
+{
+	u32 msgbuf[2];
+	s32 retval;
+
+	msgbuf[0] = NGBE_VF_SET_LPE;
+	msgbuf[1] = max_size;
+
+	retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (retval)
+		return retval;
+	if ((msgbuf[0] & NGBE_VF_SET_LPE) &&
+	    (msgbuf[0] & NGBE_VT_MSGTYPE_NACK))
+		return NGBE_ERR_MBX;
+
+	return 0;
+}
+
 /**
  *  ngbevf_negotiate_api_version - Negotiate supported API version
  *  @hw: pointer to the HW structure
@@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
 	mac->max_rx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 79891e8389..a64de9d332 100644
@@ -17,6 +17,7 @@ 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);
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 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);
drivers/net/ngbe/ngbe_ethdev_vf.c +36 -0
index d8ece38b00..5ce0c2df98 100644
@@ -272,6 +272,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct ngbe_hw *hw;
+	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+	struct rte_eth_dev_data *dev_data = dev->data;
+
+	hw = ngbe_dev_hw(dev);
+
+	if (mtu < RTE_ETHER_MIN_MTU ||
+			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+		return -EINVAL;
+
+	/* If device is started, refuse mtu that requires the support of
+	 * scattered packets when this feature has not been enabled before.
+	 */
+	if (dev_data->dev_started && !dev_data->scattered_rx &&
+	    (max_frame + 2 * RTE_VLAN_HLEN >
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+		PMD_INIT_LOG(ERR, "Stop port first.");
+		return -EINVAL;
+	}
+
+	/*
+	 * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU
+	 * request of the version 2.0 of the mailbox API.
+	 * For now, use the NGBE_VF_SET_LPE request of the version 1.0
+	 * of the mailbox API.
+	 */
+	if (ngbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
@@ -369,6 +404,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.mtu_set              = ngbevf_dev_set_mtu,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#6 lore raw

PATCH 6/15 net/ngbe: add add/remove/set mac addr ops for VF device

In reply to Zaiyu Wang

Generate a random MAC address if none was assigned by PF during the initialization of VF device. And support to add and remove MAC address.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_type.h    |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  82 +++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   4 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 146 +++++++++++++++++++++++++++
 5 files changed, 234 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 333f02c854..bbeb8aeb00 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Unicast MAC filter   = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/ngbe/base/ngbe_type.h +1 -0
index f780b92efa..7a3b52ffd4 100644
@@ -335,6 +335,7 @@ struct ngbe_mac_info {
 	/* RAR */
 	s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 			  u32 enable_addr);
+	s32 (*set_uc_addr)(struct ngbe_hw *hw, u32 index, u8 *addr);
 	s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
 	s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
 	s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
drivers/net/ngbe/base/ngbe_vf.c +82 -0

102 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +4 -0
index a64de9d332..3f328a0221 100644
@@ -16,6 +16,10 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
+		     u32 enable_addr);
+s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
drivers/net/ngbe/ngbe_ethdev_vf.c +146 -0

188 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#7 lore raw

PATCH 7/15 net/ngbe: add datapath init code for VF device

In reply to Zaiyu Wang

Add support for datapath init, including RX and TX unit init.

---
 doc/guides/nics/features/ngbe_vf.ini |   6 +
 drivers/net/ngbe/ngbe_ethdev.h       |   6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  63 ++++++++
 drivers/net/ngbe/ngbe_rxtx.c         | 210 +++++++++++++++++++++++++++
 4 files changed, 285 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +6 -0
index bbeb8aeb00..024d161c5e 100644
@@ -8,11 +8,17 @@ Unicast MAC filter   = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+Jumbo frame          = Y
+Scattered Rx         = Y
+LRO                  = Y
+TSO                  = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Rx descriptor status = Y
+Tx descriptor status = Y
 Inner L3 checksum    = P
 Inner L4 checksum    = P
 Multiprocess aware   = Y
drivers/net/ngbe/ngbe_ethdev.h +6 -0
index 7af58a57ac..37c6459f51 100644
@@ -241,6 +241,12 @@ int
 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		      struct rte_eth_burst_mode *mode);
 
+int ngbevf_dev_rx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_tx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+
 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/ngbe/ngbe_ethdev_vf.c +63 -0

81 lines not on this page · raw message

drivers/net/ngbe/ngbe_rxtx.c +210 -0

216 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#8 lore raw

PATCH 8/15 net/ngbe: add vlan related ops for VF device

In reply to Zaiyu Wang

Add support for VLAN filter, offload and strip set feature.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  32 +++++++-
 drivers/net/ngbe/base/ngbe_vf.h      |   2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 113 +++++++++++++++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 024d161c5e..e365f85e47 100644
@@ -12,6 +12,7 @@ Jumbo frame          = Y
 Scattered Rx         = Y
 LRO                  = Y
 TSO                  = Y
+VLAN filter          = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
drivers/net/ngbe/base/ngbe_vf.c +31 -1
index 18bb8d263f..d50806876f 100644
@@ -261,6 +261,35 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbe_set_vfta_vf - Set/Unset vlan filter table address
+ *  @hw: pointer to the HW structure
+ *  @vlan: 12 bit VLAN ID
+ *  @vind: unused by VF drivers
+ *  @vlan_on: if true then set bit, else clear bit
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
+ **/
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass)
+{
+	u32 msgbuf[2];
+	s32 ret_val;
+	UNREFERENCED_PARAMETER(vind, vlvf_bypass);
+
+	msgbuf[0] = NGBE_VF_SET_VLAN;
+	msgbuf[1] = vlan;
+	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
+	msgbuf[0] |= vlan_on << NGBE_VT_MSGINFO_SHIFT;
+
+	ret_val = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (!ret_val && (msgbuf[0] & NGBE_VT_MSGTYPE_ACK))
+		return 0;
+
+	return ret_val | (msgbuf[0] & NGBE_VT_MSGTYPE_NACK);
+}
+
 /**
  * ngbe_get_mac_addr_vf - Read device MAC address
  * @hw: pointer to the HW structure
@@ -440,10 +469,11 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->get_mac_addr = ngbe_get_mac_addr_vf;
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
-	/* RAR, Multicast */
+	/* RAR, Multicast, VLAN */
 	mac->set_rar = ngbe_set_rar_vf;
 	mac->set_uc_addr = ngbevf_set_uc_addr_vf;
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_vfta = ngbe_set_vfta_vf;
 	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 3f328a0221..596f41dcb0 100644
@@ -21,6 +21,8 @@ s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
drivers/net/ngbe/ngbe_ethdev_vf.c +113 -0

143 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#9 lore raw

PATCH 9/15 net/ngbe: add interrupt support for VF device

In reply to Zaiyu Wang

Add VF device interrupt handler, support to enable and disable RX queue interrupt, and configure misx interrupt.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 225 +++++++++++++++++++++++++++
 2 files changed, 226 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index e365f85e47..e7eaee1e44 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Unicast MAC filter   = Y
+Rx interrupt         = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +225 -0

293 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#10 lore raw

PATCH 10/15 net/ngbe: add link update ops for VF device

In reply to Zaiyu Wang

Add support to check link feature for VF device, including link speed, duplex mode and link state.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 96 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  9 +++
 4 files changed, 108 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index e7eaee1e44..b5c4981195 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = Y
 Unicast MAC filter   = Y
 Rx interrupt         = Y
 MTU update           = Y
drivers/net/ngbe/base/ngbe_vf.c +96 -0

108 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 596f41dcb0..5cf225dd35 100644
@@ -17,6 +17,8 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
+			    bool *link_up, bool autoneg_wait_to_complete);
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -0
index 7783fb6537..1f3f957d8a 100644
@@ -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_link_update(struct rte_eth_dev *dev,
+				   int wait_to_complete);
 static void ngbevf_intr_disable(struct rte_eth_dev *dev);
 static void ngbevf_intr_enable(struct rte_eth_dev *dev);
 static int ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
@@ -348,6 +350,12 @@ ngbevf_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+ngbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+	return ngbe_dev_link_update_share(dev, wait_to_complete);
+}
+
 static void
 ngbevf_intr_disable(struct rte_eth_dev *dev)
 {
@@ -938,6 +946,7 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.link_update          = ngbevf_dev_link_update,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
Signature · 1 line
2.21.0.windows.1
author
#11 lore raw

PATCH 11/15 net/ngbe: add stats and xstats ops for VF device

In reply to Zaiyu Wang

Add support to get stats and extended stats by reading hardware registers

---
 doc/guides/nics/features/ngbe_vf.ini |   2 +
 drivers/net/ngbe/base/ngbe_vf.h      |  32 +++++++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 137 +++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index b5c4981195..0c26db73f9 100644
@@ -24,6 +24,8 @@ Rx descriptor status = Y
 Tx descriptor status = Y
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Basic stats          = Y
+Extended stats       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_vf.h +32 -0
index 5cf225dd35..abe1655f8e 100644
@@ -11,6 +11,38 @@
 #define NGBE_VF_MAX_TX_QUEUES	1
 #define NGBE_VF_MAX_RX_QUEUES	1
 
+struct ngbevf_hw_stats {
+	u64 base_vfgprc;
+	u64 base_vfgptc;
+	u64 base_vfgorc;
+	u64 base_vfgotc;
+	u64 base_vfmprc;
+
+	u64 last_vfgprc;
+	u64 last_vfgptc;
+	u64 last_vfgorc;
+	u64 last_vfgotc;
+	u64 last_vfmprc;
+	u64 last_vfbprc;
+	u64 last_vfmptc;
+	u64 last_vfbptc;
+
+	u64 vfgprc;
+	u64 vfgptc;
+	u64 vfgorc;
+	u64 vfgotc;
+	u64 vfmprc;
+	u64 vfbprc;
+	u64 vfmptc;
+	u64 vfbptc;
+
+	u64 saved_reset_vfgprc;
+	u64 saved_reset_vfgptc;
+	u64 saved_reset_vfgorc;
+	u64 saved_reset_vfgotc;
+	u64 saved_reset_vfmprc;
+};
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
 s32 ngbe_init_hw_vf(struct ngbe_hw *hw);
 s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
drivers/net/ngbe/ngbe_ethdev_vf.c +137 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#12 lore raw

PATCH 12/15 net/ngbe: add start/stop/reset/close ops for VF device

In reply to Zaiyu Wang

Add the complete configuration process for start/stop/reset/close ops, so that applications can enable the device correctly.

---
 drivers/net/ngbe/ngbe_ethdev_vf.c | 170 +++++++++++++++++++++++++++++-
 1 file changed, 169 insertions(+), 1 deletion(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +169 -1
index 434776b26b..ac02b7ac7f 100644
@@ -555,12 +555,151 @@ ngbevf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_start(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	uint32_t intr_vector = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	int err, mask = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	err = hw->mac.reset_hw(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
+		return err;
+	}
+	hw->mac.get_link_status = true;
+
+	/* negotiate mailbox API version to use with the PF. */
+	ngbevf_negotiate_api(hw);
+
+	ngbevf_dev_tx_init(dev);
+
+	/* This can fail when allocating mbufs for descriptor rings */
+	err = ngbevf_dev_rx_init(dev);
+
+	/**
+	 * In this case, reuses the MAC address assigned by VF
+	 * initialization.
+	 */
+	if (err != 0 && err != NGBE_ERR_INVALID_MAC_ADDR) {
+		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	/* Set vfta */
+	ngbevf_set_vfta_all(dev, 1);
+
+	/* Set HW strip */
+	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
+		RTE_ETH_VLAN_EXTEND_MASK;
+	err = ngbevf_vlan_offload_config(dev, mask);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	ngbevf_dev_rxtx_start(dev);
+
+	/* check and configure queue intr-vector mapping */
+	if (rte_intr_cap_multiple(intr_handle) &&
+	    dev->data->dev_conf.intr_conf.rxq) {
+		/* According to datasheet, only vector 0/1/2 can be used,
+		 * now only one vector is used for Rx queue
+		 */
+		intr_vector = 1;
+		if (rte_intr_efd_enable(intr_handle, intr_vector))
+			return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle)) {
+		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+						   dev->data->nb_rx_queues)) {
+			PMD_INIT_LOG(ERR,
+				     "Failed to allocate %d rx_queues intr_vec",
+				     dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+	}
+
+	ngbevf_configure_msix(dev);
+
+	/* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
+	 * is mapped to VFIO vector 0 in eth_ngbevf_dev_init( ).
+	 * If previous VFIO interrupt mapping setting in eth_ngbevf_dev_init( )
+	 * is not cleared, it will fail when following rte_intr_enable( ) tries
+	 * to map Rx queue interrupt to other VFIO vectors.
+	 * So clear uio/vfio intr/evevnfd first to avoid failure.
+	 */
+	rte_intr_disable(intr_handle);
+
+	rte_intr_enable(intr_handle);
+
+	/* Re-enable interrupt for VF */
+	ngbevf_intr_enable(dev);
+
+	/*
+	 * Update link status right before return, because it may
+	 * start link configuration process in a separate thread.
+	 */
+	ngbevf_dev_link_update(dev, 0);
+
+	hw->adapter_stopped = false;
+
+	return 0;
+}
+
+static int
+ngbevf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	if (hw->adapter_stopped)
+		return 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ngbevf_intr_disable(dev);
+
+	hw->adapter_stopped = 1;
+	hw->mac.stop_hw(hw);
+
+	/*
+	 * Clear what we set, but we still keep shadow_vfta to
+	 * restore after device starts
+	 */
+	ngbevf_set_vfta_all(dev, 0);
+
+	/* Clear stored conf */
+	dev->data->scattered_rx = 0;
+
+	ngbe_dev_clear_queues(dev);
+
+	/* Clean datapath event and queue/vec mapping */
+	rte_intr_efd_disable(intr_handle);
+	rte_intr_vec_list_free(intr_handle);
+
+	adapter->rss_reta_updated = 0;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_close(struct rte_eth_dev *dev)
 {
 	struct ngbe_hw *hw = ngbe_dev_hw(dev);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -568,6 +707,10 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 
 	hw->mac.reset_hw(hw);
 
+	ret = ngbevf_dev_stop(dev);
+
+	ngbe_dev_free_queues(dev);
+
 	/**
 	 * Remove the VF MAC address ro ensure
 	 * that the VF traffic goes to the PF
@@ -588,7 +731,24 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     ngbevf_dev_interrupt_handler, dev);
 
-	return 0;
+	return ret;
+}
+
+/*
+ * Reset VF device
+ */
+static int
+ngbevf_dev_reset(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = eth_ngbevf_dev_uninit(dev);
+	if (ret)
+		return ret;
+
+	ret = eth_ngbevf_dev_init(dev);
+
+	return ret;
 }
 
 static void ngbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
@@ -1078,12 +1238,16 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.dev_start            = ngbevf_dev_start,
+	.dev_stop             = ngbevf_dev_stop,
 	.link_update          = ngbevf_dev_link_update,
 	.stats_get            = ngbevf_dev_stats_get,
 	.xstats_get           = ngbevf_dev_xstats_get,
 	.stats_reset          = ngbevf_dev_stats_reset,
 	.xstats_reset         = ngbevf_dev_stats_reset,
 	.xstats_get_names     = ngbevf_dev_xstats_get_names,
+	.dev_close            = ngbevf_dev_close,
+	.dev_reset	      = ngbevf_dev_reset,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
@@ -1093,6 +1257,10 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
 	.vlan_offload_set     = ngbevf_vlan_offload_set,
+	.rx_queue_setup       = ngbe_dev_rx_queue_setup,
+	.rx_queue_release     = ngbe_dev_rx_queue_release,
+	.tx_queue_setup       = ngbe_dev_tx_queue_setup,
+	.tx_queue_release     = ngbe_dev_tx_queue_release,
 	.rx_queue_intr_enable = ngbevf_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
Signature · 1 line
2.21.0.windows.1
author
#13 lore raw

PATCH 13/15 net/ngbe: add multicast MAC filter ops for VF device

In reply to Zaiyu Wang

Add support to update multicast MAC filter.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 81 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  3 ++
 3 files changed, 85 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 0c26db73f9..55763a311a 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Rx interrupt         = Y
 MTU update           = Y
 Promiscuous mode     = Y
drivers/net/ngbe/base/ngbe_vf.c +81 -0

99 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +3 -0
index abe1655f8e..5621ca49cb 100644
@@ -54,6 +54,9 @@ s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
+s32 ngbe_update_mc_addr_list_vf(struct ngbe_hw *hw, u8 *mc_addr_list,
+				 u32 mc_addr_count, ngbe_mc_addr_itr next,
+				 bool clear);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
 		      bool vlan_on, bool vlvf_bypass);
Signature · 1 line
2.21.0.windows.1
author
#14 lore raw

PATCH 14/15 net/ngbe: add dump registers ops for VF device

In reply to Zaiyu Wang

Add support to dump registers for VF device. Currently we only support a small number of registers. More registers will be added as needed.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 73 ++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 55763a311a..497b1031b3 100644
@@ -27,6 +27,7 @@ Inner L3 checksum    = P
 Inner L4 checksum    = P
 Basic stats          = Y
 Extended stats       = Y
+Registers dump       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +73 -0

91 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#15 lore raw

PATCH 15/15 net/ngbe: add some ops which PF has implemented

In reply to Zaiyu Wang

Some RXTX operations like queue setup and release, packet type get, and Tx done cleanup have been supported on PF device. There are ops functions directly added.

---
 doc/guides/nics/features/ngbe_vf.ini | 3 +++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 5 +++++
 2 files changed, 8 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +3 -0
index 497b1031b3..b340e75a49 100644
@@ -16,15 +16,18 @@ Scattered Rx         = Y
 LRO                  = Y
 TSO                  = Y
 VLAN filter          = Y
+Inline crypto        = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
 L3 checksum offload  = P
 L4 checksum offload  = P
+Packet type parsing  = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Free Tx mbuf on demand = Y
 Basic stats          = Y
 Extended stats       = Y
 Registers dump       = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +5 -0
index 9b2c899c74..19bcd1ac8b 100644
@@ -1325,6 +1325,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get,
 	.mtu_set              = ngbevf_dev_set_mtu,
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
@@ -1337,8 +1338,12 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
 	.mac_addr_remove      = ngbevf_remove_mac_addr,
+	.set_mc_addr_list     = ngbe_dev_set_mc_addr_list,
+	.rxq_info_get         = ngbe_rxq_info_get,
+	.txq_info_get         = ngbe_txq_info_get,
 	.mac_addr_set         = ngbevf_set_default_mac_addr,
 	.get_reg              = ngbevf_get_regs,
+	.tx_done_cleanup      = ngbe_dev_tx_done_cleanup,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
#16 lore raw
In reply to Zaiyu Wang
Quoted 29 lines · On Thu, 9 Jan 2025 12:02:10 +0800 Zaiyu Wang <[email protected]> wrote:

This patch adds support to VF device for ngbe PMD

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add vlan related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   38 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  669 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
Quoted 8 lines
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1351 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  210 ++++
 13 files changed, 2733 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c

The build fails, please fix and resubmit

*Build Failed #1:
OS: OpenAnolis8.9-64
Target: x86_64-native-linuxapp-gcc
FAILED: drivers/libtmp_rte_net_ngbe.a.p/net_ngbe_ngbe_ethdev_vf.c.o
gcc -Idrivers/libtmp_rte_net_ngbe.a.p -Idrivers -I../drivers -Idrivers/net/ngbe -I../drivers/net/ngbe -Idrivers/net/ngbe/base -I../drivers/net/ngbe/base -Ilib/ethdev -I../lib/ethdev -I. -I.. -Iconfig -I../config -Ilib/eal/include -I../lib/eal/include -Ilib/eal/linux/include -I../lib/eal/linux/include -Ilib/eal/x86/include -I../lib/eal/x86/include -I../kernel/linux -Ilib/eal/common -I../lib/eal/common -Ilib/eal -I../lib/eal -Ilib/kvargs -I../lib/kvargs -Ilib/log -I../lib/log -Ilib/metrics -I../lib/metrics -Ilib/telemetry -I../lib/telemetry -Ilib/net -I../lib/net -Ilib/mbuf -I../lib/mbuf -Ilib/mempool -I../lib/mempool -Ilib/ring -I../lib/ring -Ilib/meter -I../lib/meter -Idrivers/bus/pci -I../drivers/bus/pci -I../drivers/bus/pci/linux -Ilib/pci -I../lib/pci -Idrivers/bus/vdev -I../drivers/bus/vdev -Ilib/hash -I../lib/hash -Ilib/rcu -I../lib/rcu -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -O3 -include rte_config.h -Wcast-qual -Wdeprecated -Wformat -Wformat-nonliteral -Wformat-security -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wsign-compare -Wstrict-prototypes -Wundef -Wwrite-strings -Wno-packed-not-aligned -Wno-missing-field-initializers -D_GNU_SOURCE -fPIC -march=native -mrtm -DALLOW_EXPERIMENTAL_API -DALLOW_INTERNAL_API -Wno-format-truncation -DRTE_LOG_DEFAULT_LOGTYPE=pmd.net.ngbe -MD -MQ drivers/libtmp_rte_net_ngbe.a.p/net_ngbe_ngbe_ethdev_vf.c.o -MF drivers/libtmp_rte_net_ngbe.a.p/net_ngbe_ngbe_ethdev_vf.c.o.d -o drivers/libtmp_rte_net_ngbe.a.p/net_ngbe_ngbe_ethdev_vf.c.o -c ../drivers/net/ngbe/ngbe_ethdev_vf.c ../drivers/net/ngbe/ngbe_ethdev_vf.c: In function ‘eth_ngbevf_dev_init’:
../drivers/net/ngbe/ngbe_ethdev_vf.c:222:2: error: implicit declaration of function ‘ngbevf_dev_stats_reset’; did you mean ‘ngbevf_dev_info_get’? [-Werror=implicit-function-declaration]
ngbevf_dev_stats_reset(eth_dev);
^~~~~~~~~~~~~~~~~~~~~~
ngbevf_dev_info_get
../drivers/net/ngbe/ngbe_ethdev_vf.c:222:2: error: nested extern declaration of ‘ngbevf_dev_stats_reset’ [-Werror=nested-externs]
../drivers/net/ngbe/ngbe_ethdev_vf.c: At top level:
../drivers/net/ngbe/ngbe_ethdev_vf.c:448:1: error: static declaration of ‘ngbevf_dev_stats_reset’ follows non-static declaration
ngbevf_dev_stats_reset(struct rte_eth_dev *dev)
^~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ngbe/ngbe_ethdev_vf.c:222:2: note: previous implicit declaration of ‘ngbevf_dev_stats_reset’ was here
ngbevf_dev_stats_reset(eth_dev);
^~~~~~~~~~~~~~~~~~~~~~

author
#17 lore raw

v2 cover net/ngbe: add VF driver support

In reply to Zaiyu Wang

This patch adds support to VF device for ngbe PMD.

---
v2:
- update description of patch content
- fix build issue
- formatting and cleanup
---

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add VLAN related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   37 +
 doc/guides/nics/ngbe.rst             |   11 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  671 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1350 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  209 ++++
 14 files changed, 2743 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
Signature · 1 line
2.21.0.windows.1
author
#18 lore raw

PATCH v2 1/15 net/ngbe: add ethdev probe and remove for VF device

Introduce virtual function driver in ngbe PMD, add simple init and uninit function to probe and remove the device.

---
 doc/guides/nics/features/ngbe_vf.ini |  11 ++
 drivers/net/ngbe/base/meson.build    |   1 +
 drivers/net/ngbe/base/ngbe.h         |   1 +
 drivers/net/ngbe/base/ngbe_hw.c      |   4 +
 drivers/net/ngbe/base/ngbe_vf.c      |  26 +++++
 drivers/net/ngbe/base/ngbe_vf.h      |  13 +++
 drivers/net/ngbe/meson.build         |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 163 +++++++++++++++++++++++++++
 8 files changed, 220 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
doc/guides/nics/features/ngbe_vf.ini new file +11 -0
new file mode 100644
index 0000000000..71e7b8be81
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'ngbe_vf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file
drivers/net/ngbe/base/meson.build +1 -0
index 390b0f9c12..dd68100bf8 100644
@@ -10,6 +10,7 @@ sources = [
         'ngbe_phy_rtl.c',
         'ngbe_phy_mvl.c',
         'ngbe_phy_yt.c',
+        'ngbe_vf.c',
 ]
 
 error_cflags = []
drivers/net/ngbe/base/ngbe.h +1 -0
index 1d17c2f115..da20829c40 100644
@@ -11,5 +11,6 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_phy.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 #endif /* _NGBE_H_ */
drivers/net/ngbe/base/ngbe_hw.c +4 -0
index 29944f5070..e29a1946e5 100644
@@ -9,6 +9,7 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_mng.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 static s32 ngbe_is_lldp(struct ngbe_hw *hw)
 {
@@ -2113,6 +2114,9 @@ s32 ngbe_init_shared_code(struct ngbe_hw *hw)
 	case ngbe_mac_em:
 		ngbe_init_ops_pf(hw);
 		break;
+	case ngbe_mac_em_vf:
+		ngbe_init_ops_vf(hw);
+		break;
 	default:
 		status = NGBE_ERR_DEVICE_NOT_SUPPORTED;
 		break;
drivers/net/ngbe/base/ngbe_vf.c new file +26 -0
new file mode 100644
index 0000000000..91b8d1bbe2
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#include "ngbe_type.h"
+#include "ngbe_vf.h"
+
+/**
+ *  ngbe_init_ops_vf - Initialize the pointers for vf
+ *  @hw: pointer to hardware structure
+ *
+ *  This will assign function pointers, adapter-specific functions can
+ *  override the assignment of generic function pointers by assigning
+ *  their own adapter-specific function pointers.
+ *  Does not touch the hardware.
+ **/
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mac_info *mac = &hw->mac;
+
+	mac->max_tx_queues = 1;
+	mac->max_rx_queues = 1;
+
+	return 0;
+}
drivers/net/ngbe/base/ngbe_vf.h new file +13 -0
new file mode 100644
index 0000000000..7982ea231e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _NGBE_VF_H_
+#define _NGBE_VF_H_
+
+#include "ngbe_type.h"
+
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+
+#endif /* __NGBE_VF_H__ */
drivers/net/ngbe/meson.build +1 -0
index 402cea1c13..f4f8f7ee79 100644
@@ -15,6 +15,7 @@ sources = files(
         'ngbe_ptypes.c',
         'ngbe_pf.c',
         'ngbe_rxtx.c',
+        'ngbe_ethdev_vf.c',
 )
 
 deps += ['hash']
drivers/net/ngbe/ngbe_ethdev_vf.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
#19 lore raw

Re: [PATCH v2 01/15] net/ngbe: add ethdev probe and remove for VF device

Quoted 27 lines · On Fri, 17 Jan 2025 18:41:00 +0800 Zaiyu Wang <[email protected]> wrote:

Introduce virtual function driver in ngbe PMD, add simple init and uninit function to probe and remove the device.

---
 doc/guides/nics/features/ngbe_vf.ini |  11 ++
 drivers/net/ngbe/base/meson.build    |   1 +
 drivers/net/ngbe/base/ngbe.h         |   1 +
 drivers/net/ngbe/base/ngbe_hw.c      |   4 +
 drivers/net/ngbe/base/ngbe_vf.c      |  26 +++++
 drivers/net/ngbe/base/ngbe_vf.h      |  13 +++
 drivers/net/ngbe/meson.build         |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 163 +++++++++++++++++++++++++++
 8 files changed, 220 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
doc/guides/nics/features/ngbe_vf.ini new file +2 -0
new file mode 100644
index 0000000000..71e7b8be81
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'ngbe_vf' network poll mode driver.

doc/guides/nics/features/ngbe_vf.ini line 11

Quoted 10 lines
doc/guides/nics/features/ngbe_vf.ini new file +9 -0
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file

NAK
Fix you editor settings.

author
#20 lore raw

RE: [PATCH v2 01/15] net/ngbe: add ethdev probe and remove for VF device

Hi Stephen,
Thanks for your review. I apologize for this oversight, and I will submit a new version as soon as possible.

Quoted 23 lines
Quoted 9 lines
doc/guides/nics/features/ngbe_vf.ini new file +2 -0
new file mode 100644
index 0000000000..71e7b8be81
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'ngbe_vf' network poll mode driver.

doc/guides/nics/features/ngbe_vf.ini line 11

Quoted 10 lines
doc/guides/nics/features/ngbe_vf.ini new file +9 -0
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file

NAK
Fix you editor settings.

author
#21 lore raw

PATCH v2 2/15 net/ngbe: add support for PF-VF mailbox interface

In reply to Zaiyu Wang

Add basic code of PF-VF mailbox implementation to serve the communication between VF and PF devices.

---
 drivers/net/ngbe/base/ngbe_mbx.c  | 338 ++++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_mbx.h  |  29 +++
 drivers/net/ngbe/base/ngbe_type.h |   7 +
 drivers/net/ngbe/base/ngbe_vf.c   |  56 +++++
 drivers/net/ngbe/base/ngbe_vf.h   |   1 +
 5 files changed, 431 insertions(+)
drivers/net/ngbe/base/ngbe_mbx.c +338 -0
index bc0adbb3ec..a96a4aced7 100644
@@ -109,6 +109,344 @@ s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id)
 	return ret_val;
 }
 
+/**
+ *  ngbe_poll_for_msg - Wait for message notification
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification
+ **/
+STATIC s32 ngbe_poll_for_msg(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_msg)
+		goto out;
+
+	while (countdown && mbx->check_for_msg(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox message timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_poll_for_ack - Wait for message acknowledgment
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message acknowledgment
+ **/
+STATIC s32 ngbe_poll_for_ack(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_ack)
+		goto out;
+
+	while (countdown && mbx->check_for_ack(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox ack timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_read_posted_mbx - Wait for message notification and receive message
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification and
+ *  copied it into the receive buffer.
+ **/
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (!mbx->read)
+		goto out;
+
+	ret_val = ngbe_poll_for_msg(hw, mbx_id);
+
+	/* if ack received read message, otherwise we timed out */
+	if (!ret_val)
+		ret_val = mbx->read(hw, msg, size, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_posted_mbx - Write a message to the mailbox, wait for ack
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer and
+ *  received an ack to that message within delay * timeout period
+ **/
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size,
+			   u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* exit if either we can't write or there isn't a defined timeout */
+	if (!mbx->write || !mbx->timeout)
+		goto out;
+
+	/* send msg */
+	ret_val = mbx->write(hw, msg, size, mbx_id);
+
+	/* if msg sent wait until we receive an ack */
+	if (!ret_val)
+		ret_val = ngbe_poll_for_ack(hw, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_v2p_mailbox - read v2p mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  This function is used to read the v2p mailbox without losing the read to
+ *  clear status bits.
+ **/
+STATIC u32 ngbe_read_v2p_mailbox(struct ngbe_hw *hw)
+{
+	u32 v2p_mailbox = rd32(hw, NGBE_VFMBCTL);
+
+	v2p_mailbox |= hw->mbx.v2p_mailbox;
+	hw->mbx.v2p_mailbox |= v2p_mailbox & NGBE_VFMBCTL_R2C_BITS;
+
+	return v2p_mailbox;
+}
+
+/**
+ *  ngbe_check_for_bit_vf - Determine if a status bit was set
+ *  @hw: pointer to the HW structure
+ *  @mask: bitmask for bits to be tested and cleared
+ *
+ *  This function is used to check for the read to clear bits within
+ *  the V2P mailbox.
+ **/
+STATIC s32 ngbe_check_for_bit_vf(struct ngbe_hw *hw, u32 mask)
+{
+	u32 v2p_mailbox = ngbe_read_v2p_mailbox(hw);
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (v2p_mailbox & mask)
+		ret_val = 0;
+
+	hw->mbx.v2p_mailbox &= ~mask;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_msg_vf - checks to see if the PF has sent mail
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFSTS)) {
+		ret_val = 0;
+		hw->mbx.stats.reqs++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_ack_vf - checks to see if the PF has ACK'd
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFACK)) {
+		ret_val = 0;
+		hw->mbx.stats.acks++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_rst_vf - checks to see if the PF has reset
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns true if the PF has set the reset done bit or else false
+ **/
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, (NGBE_VFMBCTL_RSTD |
+	    NGBE_VFMBCTL_RSTI))) {
+		ret_val = 0;
+		hw->mbx.stats.rsts++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_obtain_mbx_lock_vf - obtain mailbox lock
+ *  @hw: pointer to the HW structure
+ *
+ *  return SUCCESS if we obtained the mailbox lock
+ **/
+STATIC s32 ngbe_obtain_mbx_lock_vf(struct ngbe_hw *hw)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* Take ownership of the buffer */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_VFU);
+
+	/* reserve mailbox for vf use */
+	if (ngbe_read_v2p_mailbox(hw) & NGBE_VFMBCTL_VFU)
+		ret_val = 0;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_mbx_vf - Write a message to the mailbox
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer
+ **/
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			      u16 mbx_id)
+{
+	s32 ret_val;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_write;
+
+	/* flush msg and acks as we are overwriting the message buffer */
+	ngbe_check_for_msg_vf(hw, 0);
+	ngbe_check_for_ack_vf(hw, 0);
+
+	/* copy the caller specified message to the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		wr32a(hw, NGBE_VFMBX, i, msg[i]);
+
+	/* update stats */
+	hw->mbx.stats.msgs_tx++;
+
+	/* Drop VFU and interrupt the PF to tell it a message has been sent */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_REQ);
+
+out_no_write:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_mbx_vf - Reads a message from the inbox intended for vf
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to read
+ *
+ *  returns SUCCESS if it successfully read message from buffer
+ **/
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			     u16 mbx_id)
+{
+	s32 ret_val = 0;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_read;
+
+	/* copy the message from the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		msg[i] = rd32a(hw, NGBE_VFMBX, i);
+
+	/* Acknowledge receipt and release mailbox, then we're done */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_ACK);
+
+	/* update stats */
+	hw->mbx.stats.msgs_rx++;
+
+out_no_read:
+	return ret_val;
+}
+
+/**
+ *  ngbe_init_mbx_params_vf - set initial values for vf mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  Initializes the hw->mbx struct to correct values for vf mailbox
+ */
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+
+	/* start mailbox as timed out and let the reset_hw call set the timeout
+	 * value to begin communications
+	 */
+	mbx->timeout = 0;
+	mbx->usec_delay = NGBE_VF_MBX_INIT_DELAY;
+
+	mbx->size = NGBE_P2VMBX_SIZE;
+
+	mbx->stats.msgs_tx = 0;
+	mbx->stats.msgs_rx = 0;
+	mbx->stats.reqs = 0;
+	mbx->stats.acks = 0;
+	mbx->stats.rsts = 0;
+}
+
 STATIC s32 ngbe_check_for_bit_pf(struct ngbe_hw *hw, u32 mask)
 {
 	u32 mbvficr = rd32(hw, NGBE_MBVFICR);
drivers/net/ngbe/base/ngbe_mbx.h +29 -0
index d47da2718c..83561fd4cf 100644
@@ -73,11 +73,34 @@ enum ngbevf_xcast_modes {
 
 /* length of permanent address message returned from PF */
 #define NGBE_VF_PERMADDR_MSG_LEN	4
+/* word in permanent address message with the current multicast type */
+#define NGBE_VF_MC_TYPE_WORD		3
+
+#define NGBE_PF_CONTROL_MSG		0x0100 /* PF control message */
+
+/* mailbox API, version 2.0 VF requests */
+#define NGBE_VF_API_NEGOTIATE		0x08 /* negotiate API version */
+#define NGBE_VF_GET_QUEUES		0x09 /* get queue configuration */
+#define NGBE_VF_ENABLE_MACADDR		0x0A /* enable MAC address */
+#define NGBE_VF_DISABLE_MACADDR	0x0B /* disable MAC address */
+#define NGBE_VF_GET_MACADDRS		0x0C /* get all configured MAC addrs */
+#define NGBE_VF_SET_MCAST_PROMISC	0x0D /* enable multicast promiscuous */
+#define NGBE_VF_GET_MTU		0x0E /* get bounds on MTU */
+#define NGBE_VF_SET_MTU		0x0F /* set a specific MTU */
+
+/* mailbox API, version 2.0 PF requests */
+#define NGBE_PF_TRANSPARENT_VLAN	0x0101 /* enable transparent vlan */
+
+#define NGBE_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
+#define NGBE_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
 s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw);
 void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);
 
 s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
@@ -86,4 +109,10 @@ s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);
 
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id);
+
 #endif /* _NGBE_MBX_H_ */
drivers/net/ngbe/base/ngbe_type.h +7 -0
index a987bbe25b..35ebb7208a 100644
@@ -311,6 +311,7 @@ struct ngbe_mac_info {
 	s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
 	s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
 	void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
+	s32 (*negotiate_api_version)(struct ngbe_hw *hw, int api);
 
 	/* Link */
 	s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
@@ -422,6 +423,10 @@ struct ngbe_mbx_info {
 	void (*init_params)(struct ngbe_hw *hw);
 	s32  (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
 	s32  (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
+	s32  (*read_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
+	s32  (*write_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
 	s32  (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
@@ -429,6 +434,7 @@ struct ngbe_mbx_info {
 	struct ngbe_mbx_stats stats;
 	u32 timeout;
 	u32 usec_delay;
+	u32 v2p_mailbox;
 	u16 size;
 };
 
@@ -458,6 +464,7 @@ struct ngbe_hw {
 	u8 port_id;
 	u8 revision_id;
 	bool adapter_stopped;
+	int api_version;
 	bool wol_enabled;
 	bool ncsi_enabled;
 	bool lldp_enabled;
drivers/net/ngbe/base/ngbe_vf.c +56 -0

73 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 7982ea231e..23e5b0d8a3 100644
@@ -9,5 +9,6 @@
 #include "ngbe_type.h"
 
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 
 #endif /* __NGBE_VF_H__ */
Signature · 1 line
2.21.0.windows.1
author
#22 lore raw

PATCH v2 3/15 net/ngbe: add hardware configuration code for VF device

In reply to Zaiyu Wang

Add basic hardware configure flow and device information statement.

---
 doc/guides/nics/features/ngbe_vf.ini |   7 +
 drivers/net/ngbe/base/ngbe_mbx.h     |   2 +
 drivers/net/ngbe/base/ngbe_type.h    |   5 +
 drivers/net/ngbe/base/ngbe_vf.c      | 235 +++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   9 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 114 +++++++++++++
 6 files changed, 372 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +7 -0
index 71e7b8be81..4335efb812 100644
@@ -4,6 +4,13 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+CRC offload          = P
+VLAN offload         = P
+QinQ offload         = P
+L3 checksum offload  = P
+L4 checksum offload  = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_mbx.h +2 -0
index 83561fd4cf..27e977737d 100644
@@ -57,6 +57,8 @@ enum ngbe_pfvf_api_rev {
 #define NGBE_VF_GET_RSS_KEY	0x0b    /* get RSS key */
 #define NGBE_VF_UPDATE_XCAST_MODE	0x0c
 
+#define NGBE_VF_BACKUP		0x8001 /* VF requests backup */
+
 /* mode choices for NGBE_VF_UPDATE_XCAST_MODE */
 enum ngbevf_xcast_modes {
 	NGBEVF_XCAST_MODE_NONE = 0,
drivers/net/ngbe/base/ngbe_type.h +5 -0
index 35ebb7208a..4fd7080847 100644
@@ -8,6 +8,9 @@
 
 #define NGBE_LINK_UP_TIME	90 /* 9.0 Seconds */
 
+#define NGBE_RX_HDR_SIZE	256
+#define NGBE_RX_BUF_SIZE	2048
+
 #define NGBE_FRAME_SIZE_MAX       (9728) /* Maximum frame size, +FCS */
 #define NGBE_FRAME_SIZE_DFT       (1518) /* Default frame size, +FCS */
 #define NGBE_NUM_POOL             (32)
@@ -17,6 +20,7 @@
 #define NGBE_MAX_QP               (8)
 #define NGBE_MAX_UTA              128
 
+#define NGBE_VF_INIT_TIMEOUT	200 /* Number of retries to clear RSTI */
 #define NGBE_PCI_MASTER_DISABLE_TIMEOUT	800
 #define NGBE_SPI_TIMEOUT	10000
 
@@ -480,6 +484,7 @@ struct ngbe_hw {
 	u32 q_tx_regs[8 * 4];
 	u32 gphy_efuse[2];
 	bool offset_loaded;
+	bool rx_loaded;
 	bool is_pf;
 	bool gpio_ctl;
 	bool lsc;
drivers/net/ngbe/base/ngbe_vf.c +235 -0

253 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +9 -0
index 23e5b0d8a3..da846dda45 100644
@@ -8,7 +8,16 @@
 
 #include "ngbe_type.h"
 
+#define NGBE_VF_MAX_TX_QUEUES	1
+#define NGBE_VF_MAX_RX_QUEUES	1
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+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);
 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);
 
 #endif /* __NGBE_VF_H__ */
drivers/net/ngbe/ngbe_ethdev_vf.c +114 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#23 lore raw

PATCH v2 4/15 net/ngbe: add promiscuous and allmulticast ops for VF device

In reply to Zaiyu Wang

Support to enable and disable promiscuous and allmulticast mode on VF device.

---
 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(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index 4335efb812..f8928c5a6c 100644
@@ -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
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 4fd7080847..29dcd5f912 100644
@@ -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);
drivers/net/ngbe/base/ngbe_vf.c +39 -0
index 7c8b082f97..ccf7148b9c 100644
@@ -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;
 
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index da846dda45..79891e8389 100644
@@ -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);
drivers/net/ngbe/ngbe_ethdev_vf.c +96 -0

119 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#24 lore raw

PATCH v2 5/15 net/ngbe: add set MTU ops for VF device

In reply to Zaiyu Wang

Support to update MTU for VF device.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 24 +++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 36 ++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index f8928c5a6c..570b5ac25b 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 29dcd5f912..f780b92efa 100644
@@ -352,6 +352,7 @@ struct ngbe_mac_info {
 	void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
 					bool enable, int vf);
 	s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
+	s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size);
 
 	/* Flow Control */
 	s32 (*fc_enable)(struct ngbe_hw *hw);
drivers/net/ngbe/base/ngbe_vf.c +24 -0
index ccf7148b9c..c0436c7b8a 100644
@@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbevf_rlpml_set_vf - Set the maximum receive packet length
+ *  @hw: pointer to the HW structure
+ *  @max_size: value to assign to max frame size
+ **/
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size)
+{
+	u32 msgbuf[2];
+	s32 retval;
+
+	msgbuf[0] = NGBE_VF_SET_LPE;
+	msgbuf[1] = max_size;
+
+	retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (retval)
+		return retval;
+	if ((msgbuf[0] & NGBE_VF_SET_LPE) &&
+	    (msgbuf[0] & NGBE_VT_MSGTYPE_NACK))
+		return NGBE_ERR_MBX;
+
+	return 0;
+}
+
 /**
  *  ngbevf_negotiate_api_version - Negotiate supported API version
  *  @hw: pointer to the HW structure
@@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
 	mac->max_rx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 79891e8389..a64de9d332 100644
@@ -17,6 +17,7 @@ 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);
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 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);
drivers/net/ngbe/ngbe_ethdev_vf.c +36 -0
index 28000471b5..f53c17cc82 100644
@@ -269,6 +269,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct ngbe_hw *hw;
+	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+	struct rte_eth_dev_data *dev_data = dev->data;
+
+	hw = ngbe_dev_hw(dev);
+
+	if (mtu < RTE_ETHER_MIN_MTU ||
+			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+		return -EINVAL;
+
+	/* If device is started, refuse mtu that requires the support of
+	 * scattered packets when this feature has not been enabled before.
+	 */
+	if (dev_data->dev_started && !dev_data->scattered_rx &&
+	    (max_frame + 2 * RTE_VLAN_HLEN >
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+		PMD_INIT_LOG(ERR, "Stop port first.");
+		return -EINVAL;
+	}
+
+	/*
+	 * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU
+	 * request of the version 2.0 of the mailbox API.
+	 * For now, use the NGBE_VF_SET_LPE request of the version 1.0
+	 * of the mailbox API.
+	 */
+	if (ngbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
@@ -366,6 +401,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.mtu_set              = ngbevf_dev_set_mtu,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#25 lore raw

PATCH v2 6/15 net/ngbe: add add/remove/set mac addr ops for VF device

In reply to Zaiyu Wang

Generate a random MAC address if none was assigned by PF during the initialization of VF device. And support to add and remove MAC address.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_type.h    |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  83 +++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   4 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 146 +++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 570b5ac25b..6f16f2b079 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Unicast MAC filter   = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/ngbe/base/ngbe_type.h +1 -0
index f780b92efa..7a3b52ffd4 100644
@@ -335,6 +335,7 @@ struct ngbe_mac_info {
 	/* RAR */
 	s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 			  u32 enable_addr);
+	s32 (*set_uc_addr)(struct ngbe_hw *hw, u32 index, u8 *addr);
 	s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
 	s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
 	s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
drivers/net/ngbe/base/ngbe_vf.c +83 -0

103 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +4 -0
index a64de9d332..3f328a0221 100644
@@ -16,6 +16,10 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
+		     u32 enable_addr);
+s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
drivers/net/ngbe/ngbe_ethdev_vf.c +146 -0

188 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#26 lore raw

PATCH v2 7/15 net/ngbe: add datapath init code for VF device

In reply to Zaiyu Wang

Add support for datapath init, including RX and TX unit init.

---
 doc/guides/nics/features/ngbe_vf.ini |   5 +
 doc/guides/nics/ngbe.rst             |  11 ++
 drivers/net/ngbe/ngbe_ethdev.h       |   6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  63 ++++++++
 drivers/net/ngbe/ngbe_rxtx.c         | 209 +++++++++++++++++++++++++++
 5 files changed, 294 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +5 -0
index 6f16f2b079..ad123684c5 100644
@@ -6,6 +6,9 @@
 [Features]
 Unicast MAC filter   = Y
 MTU update           = Y
+Scattered Rx         = Y
+LRO                  = Y
+TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
@@ -15,6 +18,8 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Rx descriptor status = Y
+Tx descriptor status = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
doc/guides/nics/ngbe.rst +11 -0
index e31600c95a..b002fa4c19 100644
@@ -42,6 +42,17 @@ Prerequisites
 Configuration
 -------------
 
+Compilation Options
+~~~~~~~~~~~~~~~~~~~
+
+The following build-time options may be enabled on build time using.
+
+``-Dc_args=`` meson argument (e.g. ``-Dc_args=-DRTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC``).
+
+- ``RTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC`` (undefined by default)
+
+  Decide to enable or disable HW CRC in VF PMD.
+
 Dynamic Logging Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
drivers/net/ngbe/ngbe_ethdev.h +6 -0
index 7af58a57ac..37c6459f51 100644
@@ -241,6 +241,12 @@ int
 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		      struct rte_eth_burst_mode *mode);
 
+int ngbevf_dev_rx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_tx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+
 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/ngbe/ngbe_ethdev_vf.c +63 -0

81 lines not on this page · raw message

drivers/net/ngbe/ngbe_rxtx.c +209 -0

215 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#27 lore raw

PATCH v2 8/15 net/ngbe: add VLAN related ops for VF device

In reply to Zaiyu Wang

Add support for VLAN filter, offload and strip set feature.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  33 +++++++-
 drivers/net/ngbe/base/ngbe_vf.h      |   2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 112 +++++++++++++++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index ad123684c5..48f3bd73bb 100644
@@ -11,6 +11,7 @@ LRO                  = Y
 TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
drivers/net/ngbe/base/ngbe_vf.c +32 -1
index 47fee7e14d..039f87423d 100644
@@ -262,6 +262,36 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbe_set_vfta_vf - Set/Unset vlan filter table address
+ *  @hw: pointer to the HW structure
+ *  @vlan: 12 bit VLAN ID
+ *  @vind: unused by VF drivers
+ *  @vlan_on: if true then set bit, else clear bit
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
+ **/
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass)
+{
+	u32 msgbuf[2];
+	s32 ret_val;
+
+	UNREFERENCED_PARAMETER(vind, vlvf_bypass);
+
+	msgbuf[0] = NGBE_VF_SET_VLAN;
+	msgbuf[1] = vlan;
+	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
+	msgbuf[0] |= vlan_on << NGBE_VT_MSGINFO_SHIFT;
+
+	ret_val = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (!ret_val && (msgbuf[0] & NGBE_VT_MSGTYPE_ACK))
+		return 0;
+
+	return ret_val | (msgbuf[0] & NGBE_VT_MSGTYPE_NACK);
+}
+
 /**
  * ngbe_get_mac_addr_vf - Read device MAC address
  * @hw: pointer to the HW structure
@@ -441,10 +471,11 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->get_mac_addr = ngbe_get_mac_addr_vf;
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
-	/* RAR, Multicast */
+	/* RAR, Multicast, VLAN */
 	mac->set_rar = ngbe_set_rar_vf;
 	mac->set_uc_addr = ngbevf_set_uc_addr_vf;
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_vfta = ngbe_set_vfta_vf;
 	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 3f328a0221..596f41dcb0 100644
@@ -21,6 +21,8 @@ s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
drivers/net/ngbe/ngbe_ethdev_vf.c +112 -0

142 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#28 lore raw

PATCH v2 9/15 net/ngbe: add interrupt support for VF device

In reply to Zaiyu Wang

Add VF device interrupt handler, support to enable and disable RX queue interrupt, and configure misx interrupt.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 227 +++++++++++++++++++++++++++
 2 files changed, 228 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 48f3bd73bb..0fde7f9563 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Unicast MAC filter   = Y
+Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
 LRO                  = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +227 -0

295 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#29 lore raw

PATCH v2 10/15 net/ngbe: add link update ops for VF device

In reply to Zaiyu Wang

Add support to check link feature for VF device, including link speed, duplex mode and link state.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 96 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  9 +++
 4 files changed, 108 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 0fde7f9563..fd9c30f559 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = Y
 Unicast MAC filter   = Y
 Rx interrupt         = Y
 MTU update           = Y
drivers/net/ngbe/base/ngbe_vf.c +96 -0

108 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 596f41dcb0..5cf225dd35 100644
@@ -17,6 +17,8 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
+			    bool *link_up, bool autoneg_wait_to_complete);
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -0
index 69e0e82652..7669eec2db 100644
@@ -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_link_update(struct rte_eth_dev *dev,
+				   int wait_to_complete);
 static void ngbevf_intr_disable(struct rte_eth_dev *dev);
 static void ngbevf_intr_enable(struct rte_eth_dev *dev);
 static int ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
@@ -345,6 +347,12 @@ ngbevf_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+ngbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+	return ngbe_dev_link_update_share(dev, wait_to_complete);
+}
+
 static void
 ngbevf_intr_disable(struct rte_eth_dev *dev)
 {
@@ -936,6 +944,7 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.link_update          = ngbevf_dev_link_update,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
Signature · 1 line
2.21.0.windows.1
author
#30 lore raw

PATCH v2 11/15 net/ngbe: add stats and xstats ops for VF device

In reply to Zaiyu Wang

Add support to get stats and extended stats by reading hardware registers.

---
 doc/guides/nics/features/ngbe_vf.ini |   2 +
 drivers/net/ngbe/base/ngbe_vf.h      |  32 +++++++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 138 +++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index fd9c30f559..3a45d7ec5f 100644
@@ -23,6 +23,8 @@ Inner L3 checksum    = P
 Inner L4 checksum    = P
 Rx descriptor status = Y
 Tx descriptor status = Y
+Basic stats          = Y
+Extended stats       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_vf.h +32 -0
index 5cf225dd35..abe1655f8e 100644
@@ -11,6 +11,38 @@
 #define NGBE_VF_MAX_TX_QUEUES	1
 #define NGBE_VF_MAX_RX_QUEUES	1
 
+struct ngbevf_hw_stats {
+	u64 base_vfgprc;
+	u64 base_vfgptc;
+	u64 base_vfgorc;
+	u64 base_vfgotc;
+	u64 base_vfmprc;
+
+	u64 last_vfgprc;
+	u64 last_vfgptc;
+	u64 last_vfgorc;
+	u64 last_vfgotc;
+	u64 last_vfmprc;
+	u64 last_vfbprc;
+	u64 last_vfmptc;
+	u64 last_vfbptc;
+
+	u64 vfgprc;
+	u64 vfgptc;
+	u64 vfgorc;
+	u64 vfgotc;
+	u64 vfmprc;
+	u64 vfbprc;
+	u64 vfmptc;
+	u64 vfbptc;
+
+	u64 saved_reset_vfgprc;
+	u64 saved_reset_vfgptc;
+	u64 saved_reset_vfgorc;
+	u64 saved_reset_vfgotc;
+	u64 saved_reset_vfmprc;
+};
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
 s32 ngbe_init_hw_vf(struct ngbe_hw *hw);
 s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
drivers/net/ngbe/ngbe_ethdev_vf.c +138 -0

168 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#31 lore raw

PATCH v2 12/15 net/ngbe: add start/stop/reset/close ops for VF device

In reply to Zaiyu Wang

Add the complete configuration process for start/stop/reset/close ops, so that applications can enable the device correctly.

---
 drivers/net/ngbe/ngbe_ethdev_vf.c | 170 +++++++++++++++++++++++++++++-
 1 file changed, 169 insertions(+), 1 deletion(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +169 -1
index 46710f7273..53d7767220 100644
@@ -553,12 +553,151 @@ ngbevf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_start(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	uint32_t intr_vector = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	int err, mask = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	err = hw->mac.reset_hw(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
+		return err;
+	}
+	hw->mac.get_link_status = true;
+
+	/* negotiate mailbox API version to use with the PF. */
+	ngbevf_negotiate_api(hw);
+
+	ngbevf_dev_tx_init(dev);
+
+	/* This can fail when allocating mbufs for descriptor rings */
+	err = ngbevf_dev_rx_init(dev);
+
+	/**
+	 * In this case, reuses the MAC address assigned by VF
+	 * initialization.
+	 */
+	if (err != 0 && err != NGBE_ERR_INVALID_MAC_ADDR) {
+		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	/* Set vfta */
+	ngbevf_set_vfta_all(dev, 1);
+
+	/* Set HW strip */
+	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
+		RTE_ETH_VLAN_EXTEND_MASK;
+	err = ngbevf_vlan_offload_config(dev, mask);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	ngbevf_dev_rxtx_start(dev);
+
+	/* check and configure queue intr-vector mapping */
+	if (rte_intr_cap_multiple(intr_handle) &&
+	    dev->data->dev_conf.intr_conf.rxq) {
+		/* According to datasheet, only vector 0/1/2 can be used,
+		 * now only one vector is used for Rx queue
+		 */
+		intr_vector = 1;
+		if (rte_intr_efd_enable(intr_handle, intr_vector))
+			return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle)) {
+		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+						   dev->data->nb_rx_queues)) {
+			PMD_INIT_LOG(ERR,
+				     "Failed to allocate %d rx_queues intr_vec",
+				     dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+	}
+
+	ngbevf_configure_msix(dev);
+
+	/* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
+	 * is mapped to VFIO vector 0 in eth_ngbevf_dev_init( ).
+	 * If previous VFIO interrupt mapping setting in eth_ngbevf_dev_init( )
+	 * is not cleared, it will fail when following rte_intr_enable( ) tries
+	 * to map Rx queue interrupt to other VFIO vectors.
+	 * So clear uio/vfio intr/evevnfd first to avoid failure.
+	 */
+	rte_intr_disable(intr_handle);
+
+	rte_intr_enable(intr_handle);
+
+	/* Re-enable interrupt for VF */
+	ngbevf_intr_enable(dev);
+
+	/*
+	 * Update link status right before return, because it may
+	 * start link configuration process in a separate thread.
+	 */
+	ngbevf_dev_link_update(dev, 0);
+
+	hw->adapter_stopped = false;
+
+	return 0;
+}
+
+static int
+ngbevf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	if (hw->adapter_stopped)
+		return 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ngbevf_intr_disable(dev);
+
+	hw->adapter_stopped = 1;
+	hw->mac.stop_hw(hw);
+
+	/*
+	 * Clear what we set, but we still keep shadow_vfta to
+	 * restore after device starts
+	 */
+	ngbevf_set_vfta_all(dev, 0);
+
+	/* Clear stored conf */
+	dev->data->scattered_rx = 0;
+
+	ngbe_dev_clear_queues(dev);
+
+	/* Clean datapath event and queue/vec mapping */
+	rte_intr_efd_disable(intr_handle);
+	rte_intr_vec_list_free(intr_handle);
+
+	adapter->rss_reta_updated = 0;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_close(struct rte_eth_dev *dev)
 {
 	struct ngbe_hw *hw = ngbe_dev_hw(dev);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -566,6 +705,10 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 
 	hw->mac.reset_hw(hw);
 
+	ret = ngbevf_dev_stop(dev);
+
+	ngbe_dev_free_queues(dev);
+
 	/**
 	 * Remove the VF MAC address ro ensure
 	 * that the VF traffic goes to the PF
@@ -586,7 +729,24 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     ngbevf_dev_interrupt_handler, dev);
 
-	return 0;
+	return ret;
+}
+
+/*
+ * Reset VF device
+ */
+static int
+ngbevf_dev_reset(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = eth_ngbevf_dev_uninit(dev);
+	if (ret)
+		return ret;
+
+	ret = eth_ngbevf_dev_init(dev);
+
+	return ret;
 }
 
 static void ngbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
@@ -1077,12 +1237,16 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.dev_start            = ngbevf_dev_start,
+	.dev_stop             = ngbevf_dev_stop,
 	.link_update          = ngbevf_dev_link_update,
 	.stats_get            = ngbevf_dev_stats_get,
 	.xstats_get           = ngbevf_dev_xstats_get,
 	.stats_reset          = ngbevf_dev_stats_reset,
 	.xstats_reset         = ngbevf_dev_stats_reset,
 	.xstats_get_names     = ngbevf_dev_xstats_get_names,
+	.dev_close            = ngbevf_dev_close,
+	.dev_reset	      = ngbevf_dev_reset,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
@@ -1092,6 +1256,10 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
 	.vlan_offload_set     = ngbevf_vlan_offload_set,
+	.rx_queue_setup       = ngbe_dev_rx_queue_setup,
+	.rx_queue_release     = ngbe_dev_rx_queue_release,
+	.tx_queue_setup       = ngbe_dev_tx_queue_setup,
+	.tx_queue_release     = ngbe_dev_tx_queue_release,
 	.rx_queue_intr_enable = ngbevf_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
Signature · 1 line
2.21.0.windows.1
author
#32 lore raw

PATCH v2 13/15 net/ngbe: add multicast MAC filter ops for VF device

In reply to Zaiyu Wang

Add support to update multicast MAC filter.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 81 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  3 ++
 3 files changed, 85 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 3a45d7ec5f..ceb310e719 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
drivers/net/ngbe/base/ngbe_vf.c +81 -0

99 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +3 -0
index abe1655f8e..5621ca49cb 100644
@@ -54,6 +54,9 @@ s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
+s32 ngbe_update_mc_addr_list_vf(struct ngbe_hw *hw, u8 *mc_addr_list,
+				 u32 mc_addr_count, ngbe_mc_addr_itr next,
+				 bool clear);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
 		      bool vlan_on, bool vlvf_bypass);
Signature · 1 line
2.21.0.windows.1
author
#33 lore raw

PATCH v2 14/15 net/ngbe: add dump registers ops for VF device

In reply to Zaiyu Wang

Add support to dump registers for VF device. Currently we only support a small number of registers. More registers will be added as needed.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 73 ++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index ceb310e719..909f1e00f8 100644
@@ -26,6 +26,7 @@ Rx descriptor status = Y
 Tx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
+Registers dump       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +73 -0

91 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#34 lore raw

PATCH v2 15/15 net/ngbe: add some ops which PF has implemented

In reply to Zaiyu Wang

Some RXTX operations like queue setup and release, packet type get, and Tx done cleanup have been supported on PF device. There are ops functions directly added.

---
 doc/guides/nics/features/ngbe_vf.ini | 3 +++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 5 +++++
 2 files changed, 8 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +3 -0
index 909f1e00f8..3f56e0aa26 100644
@@ -15,6 +15,7 @@ TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 VLAN filter          = Y
+Inline crypto        = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
@@ -22,8 +23,10 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Packet type parsing  = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Free Tx mbuf on demand = Y
 Basic stats          = Y
 Extended stats       = Y
 Registers dump       = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +5 -0
index 0dfc07a8fd..8c74ef308e 100644
@@ -1324,6 +1324,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get,
 	.mtu_set              = ngbevf_dev_set_mtu,
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
@@ -1336,8 +1337,12 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
 	.mac_addr_remove      = ngbevf_remove_mac_addr,
+	.set_mc_addr_list     = ngbe_dev_set_mc_addr_list,
+	.rxq_info_get         = ngbe_rxq_info_get,
+	.txq_info_get         = ngbe_txq_info_get,
 	.mac_addr_set         = ngbevf_set_default_mac_addr,
 	.get_reg              = ngbevf_get_regs,
+	.tx_done_cleanup      = ngbe_dev_tx_done_cleanup,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#35 lore raw

v3 cover net/ngbe: add VF driver support

In reply to Zaiyu Wang

This patch adds support to VF device for ngbe PMD.

---
v2:
- update description of patch content
- fix build issue
- formatting and cleanup
---
v3:
- fix Intel-compilation error
---

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add VLAN related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   37 +
 doc/guides/nics/ngbe.rst             |   11 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  671 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1353 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  209 ++++
 14 files changed, 2746 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
Signature · 1 line
2.21.0.windows.1
author
#36 lore raw

PATCH v3 1/15 net/ngbe: add ethdev probe and remove for VF device

Introduce virtual function driver in ngbe PMD, add simple init and uninit function to probe and remove the device.

---
 doc/guides/nics/features/ngbe_vf.ini |  11 ++
 drivers/net/ngbe/base/meson.build    |   1 +
 drivers/net/ngbe/base/ngbe.h         |   1 +
 drivers/net/ngbe/base/ngbe_hw.c      |   4 +
 drivers/net/ngbe/base/ngbe_vf.c      |  26 +++++
 drivers/net/ngbe/base/ngbe_vf.h      |  13 +++
 drivers/net/ngbe/meson.build         |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 163 +++++++++++++++++++++++++++
 8 files changed, 220 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
doc/guides/nics/features/ngbe_vf.ini new file +11 -0
new file mode 100644
index 0000000000..71e7b8be81
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'ngbe_vf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
\ No newline at end of file
drivers/net/ngbe/base/meson.build +1 -0
index 390b0f9c12..dd68100bf8 100644
@@ -10,6 +10,7 @@ sources = [
         'ngbe_phy_rtl.c',
         'ngbe_phy_mvl.c',
         'ngbe_phy_yt.c',
+        'ngbe_vf.c',
 ]
 
 error_cflags = []
drivers/net/ngbe/base/ngbe.h +1 -0
index 1d17c2f115..da20829c40 100644
@@ -11,5 +11,6 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_phy.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 #endif /* _NGBE_H_ */
drivers/net/ngbe/base/ngbe_hw.c +4 -0
index 29944f5070..e29a1946e5 100644
@@ -9,6 +9,7 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_mng.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 static s32 ngbe_is_lldp(struct ngbe_hw *hw)
 {
@@ -2113,6 +2114,9 @@ s32 ngbe_init_shared_code(struct ngbe_hw *hw)
 	case ngbe_mac_em:
 		ngbe_init_ops_pf(hw);
 		break;
+	case ngbe_mac_em_vf:
+		ngbe_init_ops_vf(hw);
+		break;
 	default:
 		status = NGBE_ERR_DEVICE_NOT_SUPPORTED;
 		break;
drivers/net/ngbe/base/ngbe_vf.c new file +26 -0
new file mode 100644
index 0000000000..91b8d1bbe2
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#include "ngbe_type.h"
+#include "ngbe_vf.h"
+
+/**
+ *  ngbe_init_ops_vf - Initialize the pointers for vf
+ *  @hw: pointer to hardware structure
+ *
+ *  This will assign function pointers, adapter-specific functions can
+ *  override the assignment of generic function pointers by assigning
+ *  their own adapter-specific function pointers.
+ *  Does not touch the hardware.
+ **/
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mac_info *mac = &hw->mac;
+
+	mac->max_tx_queues = 1;
+	mac->max_rx_queues = 1;
+
+	return 0;
+}
drivers/net/ngbe/base/ngbe_vf.h new file +13 -0
new file mode 100644
index 0000000000..7982ea231e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _NGBE_VF_H_
+#define _NGBE_VF_H_
+
+#include "ngbe_type.h"
+
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+
+#endif /* __NGBE_VF_H__ */
drivers/net/ngbe/meson.build +1 -0
index 402cea1c13..f4f8f7ee79 100644
@@ -15,6 +15,7 @@ sources = files(
         'ngbe_ptypes.c',
         'ngbe_pf.c',
         'ngbe_rxtx.c',
+        'ngbe_ethdev_vf.c',
 )
 
 deps += ['hash']
drivers/net/ngbe/ngbe_ethdev_vf.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#37 lore raw

PATCH v3 2/15 net/ngbe: add support for PF-VF mailbox interface

In reply to Zaiyu Wang

Add basic code of PF-VF mailbox implementation to serve the communication between VF and PF devices.

---
 drivers/net/ngbe/base/ngbe_mbx.c  | 338 ++++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_mbx.h  |  29 +++
 drivers/net/ngbe/base/ngbe_type.h |   7 +
 drivers/net/ngbe/base/ngbe_vf.c   |  56 +++++
 drivers/net/ngbe/base/ngbe_vf.h   |   1 +
 5 files changed, 431 insertions(+)
drivers/net/ngbe/base/ngbe_mbx.c +338 -0
index bc0adbb3ec..a96a4aced7 100644
@@ -109,6 +109,344 @@ s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id)
 	return ret_val;
 }
 
+/**
+ *  ngbe_poll_for_msg - Wait for message notification
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification
+ **/
+STATIC s32 ngbe_poll_for_msg(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_msg)
+		goto out;
+
+	while (countdown && mbx->check_for_msg(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox message timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_poll_for_ack - Wait for message acknowledgment
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message acknowledgment
+ **/
+STATIC s32 ngbe_poll_for_ack(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_ack)
+		goto out;
+
+	while (countdown && mbx->check_for_ack(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox ack timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_read_posted_mbx - Wait for message notification and receive message
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification and
+ *  copied it into the receive buffer.
+ **/
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (!mbx->read)
+		goto out;
+
+	ret_val = ngbe_poll_for_msg(hw, mbx_id);
+
+	/* if ack received read message, otherwise we timed out */
+	if (!ret_val)
+		ret_val = mbx->read(hw, msg, size, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_posted_mbx - Write a message to the mailbox, wait for ack
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer and
+ *  received an ack to that message within delay * timeout period
+ **/
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size,
+			   u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* exit if either we can't write or there isn't a defined timeout */
+	if (!mbx->write || !mbx->timeout)
+		goto out;
+
+	/* send msg */
+	ret_val = mbx->write(hw, msg, size, mbx_id);
+
+	/* if msg sent wait until we receive an ack */
+	if (!ret_val)
+		ret_val = ngbe_poll_for_ack(hw, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_v2p_mailbox - read v2p mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  This function is used to read the v2p mailbox without losing the read to
+ *  clear status bits.
+ **/
+STATIC u32 ngbe_read_v2p_mailbox(struct ngbe_hw *hw)
+{
+	u32 v2p_mailbox = rd32(hw, NGBE_VFMBCTL);
+
+	v2p_mailbox |= hw->mbx.v2p_mailbox;
+	hw->mbx.v2p_mailbox |= v2p_mailbox & NGBE_VFMBCTL_R2C_BITS;
+
+	return v2p_mailbox;
+}
+
+/**
+ *  ngbe_check_for_bit_vf - Determine if a status bit was set
+ *  @hw: pointer to the HW structure
+ *  @mask: bitmask for bits to be tested and cleared
+ *
+ *  This function is used to check for the read to clear bits within
+ *  the V2P mailbox.
+ **/
+STATIC s32 ngbe_check_for_bit_vf(struct ngbe_hw *hw, u32 mask)
+{
+	u32 v2p_mailbox = ngbe_read_v2p_mailbox(hw);
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (v2p_mailbox & mask)
+		ret_val = 0;
+
+	hw->mbx.v2p_mailbox &= ~mask;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_msg_vf - checks to see if the PF has sent mail
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFSTS)) {
+		ret_val = 0;
+		hw->mbx.stats.reqs++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_ack_vf - checks to see if the PF has ACK'd
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFACK)) {
+		ret_val = 0;
+		hw->mbx.stats.acks++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_rst_vf - checks to see if the PF has reset
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns true if the PF has set the reset done bit or else false
+ **/
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, (NGBE_VFMBCTL_RSTD |
+	    NGBE_VFMBCTL_RSTI))) {
+		ret_val = 0;
+		hw->mbx.stats.rsts++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_obtain_mbx_lock_vf - obtain mailbox lock
+ *  @hw: pointer to the HW structure
+ *
+ *  return SUCCESS if we obtained the mailbox lock
+ **/
+STATIC s32 ngbe_obtain_mbx_lock_vf(struct ngbe_hw *hw)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* Take ownership of the buffer */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_VFU);
+
+	/* reserve mailbox for vf use */
+	if (ngbe_read_v2p_mailbox(hw) & NGBE_VFMBCTL_VFU)
+		ret_val = 0;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_mbx_vf - Write a message to the mailbox
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer
+ **/
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			      u16 mbx_id)
+{
+	s32 ret_val;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_write;
+
+	/* flush msg and acks as we are overwriting the message buffer */
+	ngbe_check_for_msg_vf(hw, 0);
+	ngbe_check_for_ack_vf(hw, 0);
+
+	/* copy the caller specified message to the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		wr32a(hw, NGBE_VFMBX, i, msg[i]);
+
+	/* update stats */
+	hw->mbx.stats.msgs_tx++;
+
+	/* Drop VFU and interrupt the PF to tell it a message has been sent */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_REQ);
+
+out_no_write:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_mbx_vf - Reads a message from the inbox intended for vf
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to read
+ *
+ *  returns SUCCESS if it successfully read message from buffer
+ **/
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			     u16 mbx_id)
+{
+	s32 ret_val = 0;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_read;
+
+	/* copy the message from the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		msg[i] = rd32a(hw, NGBE_VFMBX, i);
+
+	/* Acknowledge receipt and release mailbox, then we're done */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_ACK);
+
+	/* update stats */
+	hw->mbx.stats.msgs_rx++;
+
+out_no_read:
+	return ret_val;
+}
+
+/**
+ *  ngbe_init_mbx_params_vf - set initial values for vf mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  Initializes the hw->mbx struct to correct values for vf mailbox
+ */
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+
+	/* start mailbox as timed out and let the reset_hw call set the timeout
+	 * value to begin communications
+	 */
+	mbx->timeout = 0;
+	mbx->usec_delay = NGBE_VF_MBX_INIT_DELAY;
+
+	mbx->size = NGBE_P2VMBX_SIZE;
+
+	mbx->stats.msgs_tx = 0;
+	mbx->stats.msgs_rx = 0;
+	mbx->stats.reqs = 0;
+	mbx->stats.acks = 0;
+	mbx->stats.rsts = 0;
+}
+
 STATIC s32 ngbe_check_for_bit_pf(struct ngbe_hw *hw, u32 mask)
 {
 	u32 mbvficr = rd32(hw, NGBE_MBVFICR);
drivers/net/ngbe/base/ngbe_mbx.h +29 -0
index d47da2718c..83561fd4cf 100644
@@ -73,11 +73,34 @@ enum ngbevf_xcast_modes {
 
 /* length of permanent address message returned from PF */
 #define NGBE_VF_PERMADDR_MSG_LEN	4
+/* word in permanent address message with the current multicast type */
+#define NGBE_VF_MC_TYPE_WORD		3
+
+#define NGBE_PF_CONTROL_MSG		0x0100 /* PF control message */
+
+/* mailbox API, version 2.0 VF requests */
+#define NGBE_VF_API_NEGOTIATE		0x08 /* negotiate API version */
+#define NGBE_VF_GET_QUEUES		0x09 /* get queue configuration */
+#define NGBE_VF_ENABLE_MACADDR		0x0A /* enable MAC address */
+#define NGBE_VF_DISABLE_MACADDR	0x0B /* disable MAC address */
+#define NGBE_VF_GET_MACADDRS		0x0C /* get all configured MAC addrs */
+#define NGBE_VF_SET_MCAST_PROMISC	0x0D /* enable multicast promiscuous */
+#define NGBE_VF_GET_MTU		0x0E /* get bounds on MTU */
+#define NGBE_VF_SET_MTU		0x0F /* set a specific MTU */
+
+/* mailbox API, version 2.0 PF requests */
+#define NGBE_PF_TRANSPARENT_VLAN	0x0101 /* enable transparent vlan */
+
+#define NGBE_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
+#define NGBE_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
 s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw);
 void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);
 
 s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
@@ -86,4 +109,10 @@ s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);
 
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id);
+
 #endif /* _NGBE_MBX_H_ */
drivers/net/ngbe/base/ngbe_type.h +7 -0
index a987bbe25b..35ebb7208a 100644
@@ -311,6 +311,7 @@ struct ngbe_mac_info {
 	s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
 	s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
 	void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
+	s32 (*negotiate_api_version)(struct ngbe_hw *hw, int api);
 
 	/* Link */
 	s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
@@ -422,6 +423,10 @@ struct ngbe_mbx_info {
 	void (*init_params)(struct ngbe_hw *hw);
 	s32  (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
 	s32  (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
+	s32  (*read_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
+	s32  (*write_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
 	s32  (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
@@ -429,6 +434,7 @@ struct ngbe_mbx_info {
 	struct ngbe_mbx_stats stats;
 	u32 timeout;
 	u32 usec_delay;
+	u32 v2p_mailbox;
 	u16 size;
 };
 
@@ -458,6 +464,7 @@ struct ngbe_hw {
 	u8 port_id;
 	u8 revision_id;
 	bool adapter_stopped;
+	int api_version;
 	bool wol_enabled;
 	bool ncsi_enabled;
 	bool lldp_enabled;
drivers/net/ngbe/base/ngbe_vf.c +56 -0

73 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 7982ea231e..23e5b0d8a3 100644
@@ -9,5 +9,6 @@
 #include "ngbe_type.h"
 
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 
 #endif /* __NGBE_VF_H__ */
Signature · 1 line
2.21.0.windows.1
author
#38 lore raw

PATCH v3 3/15 net/ngbe: add hardware configuration code for VF device

In reply to Zaiyu Wang

Add basic hardware configure flow and device information statement.

---
 doc/guides/nics/features/ngbe_vf.ini |   7 +
 drivers/net/ngbe/base/ngbe_mbx.h     |   2 +
 drivers/net/ngbe/base/ngbe_type.h    |   5 +
 drivers/net/ngbe/base/ngbe_vf.c      | 235 +++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   9 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 114 +++++++++++++
 6 files changed, 372 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +7 -0
index 71e7b8be81..4335efb812 100644
@@ -4,6 +4,13 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+CRC offload          = P
+VLAN offload         = P
+QinQ offload         = P
+L3 checksum offload  = P
+L4 checksum offload  = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_mbx.h +2 -0
index 83561fd4cf..27e977737d 100644
@@ -57,6 +57,8 @@ enum ngbe_pfvf_api_rev {
 #define NGBE_VF_GET_RSS_KEY	0x0b    /* get RSS key */
 #define NGBE_VF_UPDATE_XCAST_MODE	0x0c
 
+#define NGBE_VF_BACKUP		0x8001 /* VF requests backup */
+
 /* mode choices for NGBE_VF_UPDATE_XCAST_MODE */
 enum ngbevf_xcast_modes {
 	NGBEVF_XCAST_MODE_NONE = 0,
drivers/net/ngbe/base/ngbe_type.h +5 -0
index 35ebb7208a..4fd7080847 100644
@@ -8,6 +8,9 @@
 
 #define NGBE_LINK_UP_TIME	90 /* 9.0 Seconds */
 
+#define NGBE_RX_HDR_SIZE	256
+#define NGBE_RX_BUF_SIZE	2048
+
 #define NGBE_FRAME_SIZE_MAX       (9728) /* Maximum frame size, +FCS */
 #define NGBE_FRAME_SIZE_DFT       (1518) /* Default frame size, +FCS */
 #define NGBE_NUM_POOL             (32)
@@ -17,6 +20,7 @@
 #define NGBE_MAX_QP               (8)
 #define NGBE_MAX_UTA              128
 
+#define NGBE_VF_INIT_TIMEOUT	200 /* Number of retries to clear RSTI */
 #define NGBE_PCI_MASTER_DISABLE_TIMEOUT	800
 #define NGBE_SPI_TIMEOUT	10000
 
@@ -480,6 +484,7 @@ struct ngbe_hw {
 	u32 q_tx_regs[8 * 4];
 	u32 gphy_efuse[2];
 	bool offset_loaded;
+	bool rx_loaded;
 	bool is_pf;
 	bool gpio_ctl;
 	bool lsc;
drivers/net/ngbe/base/ngbe_vf.c +235 -0

253 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +9 -0
index 23e5b0d8a3..da846dda45 100644
@@ -8,7 +8,16 @@
 
 #include "ngbe_type.h"
 
+#define NGBE_VF_MAX_TX_QUEUES	1
+#define NGBE_VF_MAX_RX_QUEUES	1
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+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);
 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);
 
 #endif /* __NGBE_VF_H__ */
drivers/net/ngbe/ngbe_ethdev_vf.c +114 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#39 lore raw

PATCH v3 4/15 net/ngbe: add promiscuous and allmulticast ops for VF device

In reply to Zaiyu Wang

Support to enable and disable promiscuous and allmulticast mode on VF device.

---
 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(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index 4335efb812..f8928c5a6c 100644
@@ -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
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 4fd7080847..29dcd5f912 100644
@@ -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);
drivers/net/ngbe/base/ngbe_vf.c +39 -0
index 7c8b082f97..ccf7148b9c 100644
@@ -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;
 
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index da846dda45..79891e8389 100644
@@ -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);
drivers/net/ngbe/ngbe_ethdev_vf.c +96 -0

119 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#40 lore raw

PATCH v3 5/15 net/ngbe: add set MTU ops for VF device

In reply to Zaiyu Wang

Support to update MTU for VF device.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 24 +++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 36 ++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index f8928c5a6c..570b5ac25b 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 29dcd5f912..f780b92efa 100644
@@ -352,6 +352,7 @@ struct ngbe_mac_info {
 	void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
 					bool enable, int vf);
 	s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
+	s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size);
 
 	/* Flow Control */
 	s32 (*fc_enable)(struct ngbe_hw *hw);
drivers/net/ngbe/base/ngbe_vf.c +24 -0
index ccf7148b9c..c0436c7b8a 100644
@@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbevf_rlpml_set_vf - Set the maximum receive packet length
+ *  @hw: pointer to the HW structure
+ *  @max_size: value to assign to max frame size
+ **/
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size)
+{
+	u32 msgbuf[2];
+	s32 retval;
+
+	msgbuf[0] = NGBE_VF_SET_LPE;
+	msgbuf[1] = max_size;
+
+	retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (retval)
+		return retval;
+	if ((msgbuf[0] & NGBE_VF_SET_LPE) &&
+	    (msgbuf[0] & NGBE_VT_MSGTYPE_NACK))
+		return NGBE_ERR_MBX;
+
+	return 0;
+}
+
 /**
  *  ngbevf_negotiate_api_version - Negotiate supported API version
  *  @hw: pointer to the HW structure
@@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
 	mac->max_rx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 79891e8389..a64de9d332 100644
@@ -17,6 +17,7 @@ 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);
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 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);
drivers/net/ngbe/ngbe_ethdev_vf.c +36 -0
index 28000471b5..f53c17cc82 100644
@@ -269,6 +269,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct ngbe_hw *hw;
+	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+	struct rte_eth_dev_data *dev_data = dev->data;
+
+	hw = ngbe_dev_hw(dev);
+
+	if (mtu < RTE_ETHER_MIN_MTU ||
+			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+		return -EINVAL;
+
+	/* If device is started, refuse mtu that requires the support of
+	 * scattered packets when this feature has not been enabled before.
+	 */
+	if (dev_data->dev_started && !dev_data->scattered_rx &&
+	    (max_frame + 2 * RTE_VLAN_HLEN >
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+		PMD_INIT_LOG(ERR, "Stop port first.");
+		return -EINVAL;
+	}
+
+	/*
+	 * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU
+	 * request of the version 2.0 of the mailbox API.
+	 * For now, use the NGBE_VF_SET_LPE request of the version 1.0
+	 * of the mailbox API.
+	 */
+	if (ngbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
@@ -366,6 +401,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.mtu_set              = ngbevf_dev_set_mtu,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#41 lore raw

PATCH v3 6/15 net/ngbe: add add/remove/set mac addr ops for VF device

In reply to Zaiyu Wang

Generate a random MAC address if none was assigned by PF during the initialization of VF device. And support to add and remove MAC address.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_type.h    |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  83 +++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   4 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 146 +++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 570b5ac25b..6f16f2b079 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Unicast MAC filter   = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/ngbe/base/ngbe_type.h +1 -0
index f780b92efa..7a3b52ffd4 100644
@@ -335,6 +335,7 @@ struct ngbe_mac_info {
 	/* RAR */
 	s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 			  u32 enable_addr);
+	s32 (*set_uc_addr)(struct ngbe_hw *hw, u32 index, u8 *addr);
 	s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
 	s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
 	s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
drivers/net/ngbe/base/ngbe_vf.c +83 -0

103 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +4 -0
index a64de9d332..3f328a0221 100644
@@ -16,6 +16,10 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
+		     u32 enable_addr);
+s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
drivers/net/ngbe/ngbe_ethdev_vf.c +146 -0

188 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#42 lore raw

PATCH v3 7/15 net/ngbe: add datapath init code for VF device

In reply to Zaiyu Wang

Add support for datapath init, including RX and TX unit init.

---
 doc/guides/nics/features/ngbe_vf.ini |   5 +
 doc/guides/nics/ngbe.rst             |  11 ++
 drivers/net/ngbe/ngbe_ethdev.h       |   6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  63 ++++++++
 drivers/net/ngbe/ngbe_rxtx.c         | 209 +++++++++++++++++++++++++++
 5 files changed, 294 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +5 -0
index 6f16f2b079..ad123684c5 100644
@@ -6,6 +6,9 @@
 [Features]
 Unicast MAC filter   = Y
 MTU update           = Y
+Scattered Rx         = Y
+LRO                  = Y
+TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
@@ -15,6 +18,8 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Rx descriptor status = Y
+Tx descriptor status = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
doc/guides/nics/ngbe.rst +11 -0
index e31600c95a..b002fa4c19 100644
@@ -42,6 +42,17 @@ Prerequisites
 Configuration
 -------------
 
+Compilation Options
+~~~~~~~~~~~~~~~~~~~
+
+The following build-time options may be enabled on build time using.
+
+``-Dc_args=`` meson argument (e.g. ``-Dc_args=-DRTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC``).
+
+- ``RTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC`` (undefined by default)
+
+  Decide to enable or disable HW CRC in VF PMD.
+
 Dynamic Logging Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
drivers/net/ngbe/ngbe_ethdev.h +6 -0
index 7af58a57ac..37c6459f51 100644
@@ -241,6 +241,12 @@ int
 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		      struct rte_eth_burst_mode *mode);
 
+int ngbevf_dev_rx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_tx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+
 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/ngbe/ngbe_ethdev_vf.c +63 -0

81 lines not on this page · raw message

drivers/net/ngbe/ngbe_rxtx.c +209 -0

215 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#43 lore raw

PATCH v3 8/15 net/ngbe: add VLAN related ops for VF device

In reply to Zaiyu Wang

Add support for VLAN filter, offload and strip set feature.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  33 +++++++-
 drivers/net/ngbe/base/ngbe_vf.h      |   2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 112 +++++++++++++++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index ad123684c5..48f3bd73bb 100644
@@ -11,6 +11,7 @@ LRO                  = Y
 TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
drivers/net/ngbe/base/ngbe_vf.c +32 -1
index 47fee7e14d..039f87423d 100644
@@ -262,6 +262,36 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbe_set_vfta_vf - Set/Unset vlan filter table address
+ *  @hw: pointer to the HW structure
+ *  @vlan: 12 bit VLAN ID
+ *  @vind: unused by VF drivers
+ *  @vlan_on: if true then set bit, else clear bit
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
+ **/
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass)
+{
+	u32 msgbuf[2];
+	s32 ret_val;
+
+	UNREFERENCED_PARAMETER(vind, vlvf_bypass);
+
+	msgbuf[0] = NGBE_VF_SET_VLAN;
+	msgbuf[1] = vlan;
+	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
+	msgbuf[0] |= vlan_on << NGBE_VT_MSGINFO_SHIFT;
+
+	ret_val = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (!ret_val && (msgbuf[0] & NGBE_VT_MSGTYPE_ACK))
+		return 0;
+
+	return ret_val | (msgbuf[0] & NGBE_VT_MSGTYPE_NACK);
+}
+
 /**
  * ngbe_get_mac_addr_vf - Read device MAC address
  * @hw: pointer to the HW structure
@@ -441,10 +471,11 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->get_mac_addr = ngbe_get_mac_addr_vf;
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
-	/* RAR, Multicast */
+	/* RAR, Multicast, VLAN */
 	mac->set_rar = ngbe_set_rar_vf;
 	mac->set_uc_addr = ngbevf_set_uc_addr_vf;
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_vfta = ngbe_set_vfta_vf;
 	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 3f328a0221..596f41dcb0 100644
@@ -21,6 +21,8 @@ s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
drivers/net/ngbe/ngbe_ethdev_vf.c +112 -0

142 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#44 lore raw

PATCH v3 9/15 net/ngbe: add interrupt support for VF device

In reply to Zaiyu Wang

Add VF device interrupt handler, support to enable and disable RX queue interrupt, and configure misx interrupt.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 230 +++++++++++++++++++++++++++
 2 files changed, 231 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 48f3bd73bb..0fde7f9563 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Unicast MAC filter   = Y
+Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
 LRO                  = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +230 -0

298 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#45 lore raw

PATCH v3 10/15 net/ngbe: add link update ops for VF device

In reply to Zaiyu Wang

Add support to check link feature for VF device, including link speed, duplex mode and link state.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 96 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  9 +++
 4 files changed, 108 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 0fde7f9563..fd9c30f559 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = Y
 Unicast MAC filter   = Y
 Rx interrupt         = Y
 MTU update           = Y
drivers/net/ngbe/base/ngbe_vf.c +96 -0

108 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 596f41dcb0..5cf225dd35 100644
@@ -17,6 +17,8 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
+			    bool *link_up, bool autoneg_wait_to_complete);
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -0
index e1ba8b02d2..01e9d5d8ee 100644
@@ -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_link_update(struct rte_eth_dev *dev,
+				   int wait_to_complete);
 static void ngbevf_intr_disable(struct rte_eth_dev *dev);
 static void ngbevf_intr_enable(struct rte_eth_dev *dev);
 static int ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
@@ -345,6 +347,12 @@ ngbevf_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+ngbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+	return ngbe_dev_link_update_share(dev, wait_to_complete);
+}
+
 static void
 ngbevf_intr_disable(struct rte_eth_dev *dev)
 {
@@ -939,6 +947,7 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.link_update          = ngbevf_dev_link_update,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
Signature · 1 line
2.21.0.windows.1
author
#46 lore raw

PATCH v3 11/15 net/ngbe: add stats and xstats ops for VF device

In reply to Zaiyu Wang

Add support to get stats and extended stats by reading hardware registers.

---
 doc/guides/nics/features/ngbe_vf.ini |   2 +
 drivers/net/ngbe/base/ngbe_vf.h      |  32 +++++++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 138 +++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index fd9c30f559..3a45d7ec5f 100644
@@ -23,6 +23,8 @@ Inner L3 checksum    = P
 Inner L4 checksum    = P
 Rx descriptor status = Y
 Tx descriptor status = Y
+Basic stats          = Y
+Extended stats       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_vf.h +32 -0
index 5cf225dd35..abe1655f8e 100644
@@ -11,6 +11,38 @@
 #define NGBE_VF_MAX_TX_QUEUES	1
 #define NGBE_VF_MAX_RX_QUEUES	1
 
+struct ngbevf_hw_stats {
+	u64 base_vfgprc;
+	u64 base_vfgptc;
+	u64 base_vfgorc;
+	u64 base_vfgotc;
+	u64 base_vfmprc;
+
+	u64 last_vfgprc;
+	u64 last_vfgptc;
+	u64 last_vfgorc;
+	u64 last_vfgotc;
+	u64 last_vfmprc;
+	u64 last_vfbprc;
+	u64 last_vfmptc;
+	u64 last_vfbptc;
+
+	u64 vfgprc;
+	u64 vfgptc;
+	u64 vfgorc;
+	u64 vfgotc;
+	u64 vfmprc;
+	u64 vfbprc;
+	u64 vfmptc;
+	u64 vfbptc;
+
+	u64 saved_reset_vfgprc;
+	u64 saved_reset_vfgptc;
+	u64 saved_reset_vfgorc;
+	u64 saved_reset_vfgotc;
+	u64 saved_reset_vfmprc;
+};
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
 s32 ngbe_init_hw_vf(struct ngbe_hw *hw);
 s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
drivers/net/ngbe/ngbe_ethdev_vf.c +138 -0

168 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#47 lore raw

PATCH v3 12/15 net/ngbe: add start/stop/reset/close ops for VF device

In reply to Zaiyu Wang

Add the complete configuration process for start/stop/reset/close ops, so that applications can enable the device correctly.

---
 drivers/net/ngbe/ngbe_ethdev_vf.c | 170 +++++++++++++++++++++++++++++-
 1 file changed, 169 insertions(+), 1 deletion(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +169 -1
index 93d801a1f3..e0e5950672 100644
@@ -553,12 +553,151 @@ ngbevf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_start(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	uint32_t intr_vector = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	int err, mask = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	err = hw->mac.reset_hw(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
+		return err;
+	}
+	hw->mac.get_link_status = true;
+
+	/* negotiate mailbox API version to use with the PF. */
+	ngbevf_negotiate_api(hw);
+
+	ngbevf_dev_tx_init(dev);
+
+	/* This can fail when allocating mbufs for descriptor rings */
+	err = ngbevf_dev_rx_init(dev);
+
+	/**
+	 * In this case, reuses the MAC address assigned by VF
+	 * initialization.
+	 */
+	if (err != 0 && err != NGBE_ERR_INVALID_MAC_ADDR) {
+		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	/* Set vfta */
+	ngbevf_set_vfta_all(dev, 1);
+
+	/* Set HW strip */
+	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
+		RTE_ETH_VLAN_EXTEND_MASK;
+	err = ngbevf_vlan_offload_config(dev, mask);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	ngbevf_dev_rxtx_start(dev);
+
+	/* check and configure queue intr-vector mapping */
+	if (rte_intr_cap_multiple(intr_handle) &&
+	    dev->data->dev_conf.intr_conf.rxq) {
+		/* According to datasheet, only vector 0/1/2 can be used,
+		 * now only one vector is used for Rx queue
+		 */
+		intr_vector = 1;
+		if (rte_intr_efd_enable(intr_handle, intr_vector))
+			return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle)) {
+		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+						   dev->data->nb_rx_queues)) {
+			PMD_INIT_LOG(ERR,
+				     "Failed to allocate %d rx_queues intr_vec",
+				     dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+	}
+
+	ngbevf_configure_msix(dev);
+
+	/* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
+	 * is mapped to VFIO vector 0 in eth_ngbevf_dev_init( ).
+	 * If previous VFIO interrupt mapping setting in eth_ngbevf_dev_init( )
+	 * is not cleared, it will fail when following rte_intr_enable( ) tries
+	 * to map Rx queue interrupt to other VFIO vectors.
+	 * So clear uio/vfio intr/evevnfd first to avoid failure.
+	 */
+	rte_intr_disable(intr_handle);
+
+	rte_intr_enable(intr_handle);
+
+	/* Re-enable interrupt for VF */
+	ngbevf_intr_enable(dev);
+
+	/*
+	 * Update link status right before return, because it may
+	 * start link configuration process in a separate thread.
+	 */
+	ngbevf_dev_link_update(dev, 0);
+
+	hw->adapter_stopped = false;
+
+	return 0;
+}
+
+static int
+ngbevf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	if (hw->adapter_stopped)
+		return 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ngbevf_intr_disable(dev);
+
+	hw->adapter_stopped = 1;
+	hw->mac.stop_hw(hw);
+
+	/*
+	 * Clear what we set, but we still keep shadow_vfta to
+	 * restore after device starts
+	 */
+	ngbevf_set_vfta_all(dev, 0);
+
+	/* Clear stored conf */
+	dev->data->scattered_rx = 0;
+
+	ngbe_dev_clear_queues(dev);
+
+	/* Clean datapath event and queue/vec mapping */
+	rte_intr_efd_disable(intr_handle);
+	rte_intr_vec_list_free(intr_handle);
+
+	adapter->rss_reta_updated = 0;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_close(struct rte_eth_dev *dev)
 {
 	struct ngbe_hw *hw = ngbe_dev_hw(dev);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -566,6 +705,10 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 
 	hw->mac.reset_hw(hw);
 
+	ret = ngbevf_dev_stop(dev);
+
+	ngbe_dev_free_queues(dev);
+
 	/**
 	 * Remove the VF MAC address ro ensure
 	 * that the VF traffic goes to the PF
@@ -586,7 +729,24 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     ngbevf_dev_interrupt_handler, dev);
 
-	return 0;
+	return ret;
+}
+
+/*
+ * Reset VF device
+ */
+static int
+ngbevf_dev_reset(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = eth_ngbevf_dev_uninit(dev);
+	if (ret)
+		return ret;
+
+	ret = eth_ngbevf_dev_init(dev);
+
+	return ret;
 }
 
 static void ngbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
@@ -1080,12 +1240,16 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.dev_start            = ngbevf_dev_start,
+	.dev_stop             = ngbevf_dev_stop,
 	.link_update          = ngbevf_dev_link_update,
 	.stats_get            = ngbevf_dev_stats_get,
 	.xstats_get           = ngbevf_dev_xstats_get,
 	.stats_reset          = ngbevf_dev_stats_reset,
 	.xstats_reset         = ngbevf_dev_stats_reset,
 	.xstats_get_names     = ngbevf_dev_xstats_get_names,
+	.dev_close            = ngbevf_dev_close,
+	.dev_reset	      = ngbevf_dev_reset,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
@@ -1095,6 +1259,10 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
 	.vlan_offload_set     = ngbevf_vlan_offload_set,
+	.rx_queue_setup       = ngbe_dev_rx_queue_setup,
+	.rx_queue_release     = ngbe_dev_rx_queue_release,
+	.tx_queue_setup       = ngbe_dev_tx_queue_setup,
+	.tx_queue_release     = ngbe_dev_tx_queue_release,
 	.rx_queue_intr_enable = ngbevf_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
Signature · 1 line
2.21.0.windows.1
author
#48 lore raw

PATCH v3 13/15 net/ngbe: add multicast MAC filter ops for VF device

In reply to Zaiyu Wang

Add support to update multicast MAC filter.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 81 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  3 ++
 3 files changed, 85 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 3a45d7ec5f..ceb310e719 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
drivers/net/ngbe/base/ngbe_vf.c +81 -0

99 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +3 -0
index abe1655f8e..5621ca49cb 100644
@@ -54,6 +54,9 @@ s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
+s32 ngbe_update_mc_addr_list_vf(struct ngbe_hw *hw, u8 *mc_addr_list,
+				 u32 mc_addr_count, ngbe_mc_addr_itr next,
+				 bool clear);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
 		      bool vlan_on, bool vlvf_bypass);
Signature · 1 line
2.21.0.windows.1
author
#49 lore raw

PATCH v3 14/15 net/ngbe: add dump registers ops for VF device

In reply to Zaiyu Wang

Add support to dump registers for VF device. Currently we only support a small number of registers. More registers will be added as needed.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 73 ++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index ceb310e719..909f1e00f8 100644
@@ -26,6 +26,7 @@ Rx descriptor status = Y
 Tx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
+Registers dump       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +73 -0

91 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#50 lore raw

PATCH v3 15/15 net/ngbe: add some ops which PF has implemented

In reply to Zaiyu Wang

Some RXTX operations like queue setup and release, packet type get, and Tx done cleanup have been supported on PF device. There are ops functions directly added.

---
 doc/guides/nics/features/ngbe_vf.ini | 3 +++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 5 +++++
 2 files changed, 8 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +3 -0
index 909f1e00f8..3f56e0aa26 100644
@@ -15,6 +15,7 @@ TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 VLAN filter          = Y
+Inline crypto        = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
@@ -22,8 +23,10 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Packet type parsing  = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Free Tx mbuf on demand = Y
 Basic stats          = Y
 Extended stats       = Y
 Registers dump       = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +5 -0
index bbd9fea328..5d68f1602d 100644
@@ -1327,6 +1327,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get,
 	.mtu_set              = ngbevf_dev_set_mtu,
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
@@ -1339,8 +1340,12 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
 	.mac_addr_remove      = ngbevf_remove_mac_addr,
+	.set_mc_addr_list     = ngbe_dev_set_mc_addr_list,
+	.rxq_info_get         = ngbe_rxq_info_get,
+	.txq_info_get         = ngbe_txq_info_get,
 	.mac_addr_set         = ngbevf_set_default_mac_addr,
 	.get_reg              = ngbevf_get_regs,
+	.tx_done_cleanup      = ngbe_dev_tx_done_cleanup,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#51 lore raw

v4 cover net/ngbe: add VF driver support

In reply to Zaiyu Wang

This patch adds support to VF device for ngbe PMD.

---
v2:
- update description of patch content
- fix build issue
- formatting and cleanup
---
v3:
- fix Intel-compilation error
---
v4:
- fix to add Line Feed at the end of files
---

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add VLAN related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   37 +
 doc/guides/nics/ngbe.rst             |   11 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  671 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1353 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  209 ++++
 14 files changed, 2746 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
Signature · 1 line
2.21.0.windows.1
author
#52 lore raw

PATCH v4 1/15 net/ngbe: add ethdev probe and remove for VF device

Introduce virtual function driver in ngbe PMD, add simple init and uninit function to probe and remove the device.

---
 doc/guides/nics/features/ngbe_vf.ini |  11 ++
 drivers/net/ngbe/base/meson.build    |   1 +
 drivers/net/ngbe/base/ngbe.h         |   1 +
 drivers/net/ngbe/base/ngbe_hw.c      |   4 +
 drivers/net/ngbe/base/ngbe_vf.c      |  26 +++++
 drivers/net/ngbe/base/ngbe_vf.h      |  13 +++
 drivers/net/ngbe/meson.build         |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 163 +++++++++++++++++++++++++++
 8 files changed, 220 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c
doc/guides/nics/features/ngbe_vf.ini new file +11 -0
new file mode 100644
index 0000000000..4da36e0085
@@ -0,0 +1,11 @@
+;
+; Supported features of the 'ngbe_vf' network poll mode driver.
+;
+; Refer to default.ini for the full list of available PMD features.
+;
+[Features]
+Multiprocess aware   = Y
+Linux                = Y
+ARMv8                = Y
+x86-32               = Y
+x86-64               = Y
drivers/net/ngbe/base/meson.build +1 -0
index 390b0f9c12..dd68100bf8 100644
@@ -10,6 +10,7 @@ sources = [
         'ngbe_phy_rtl.c',
         'ngbe_phy_mvl.c',
         'ngbe_phy_yt.c',
+        'ngbe_vf.c',
 ]
 
 error_cflags = []
drivers/net/ngbe/base/ngbe.h +1 -0
index 1d17c2f115..da20829c40 100644
@@ -11,5 +11,6 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_phy.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 #endif /* _NGBE_H_ */
drivers/net/ngbe/base/ngbe_hw.c +4 -0
index 29944f5070..e29a1946e5 100644
@@ -9,6 +9,7 @@
 #include "ngbe_eeprom.h"
 #include "ngbe_mng.h"
 #include "ngbe_hw.h"
+#include "ngbe_vf.h"
 
 static s32 ngbe_is_lldp(struct ngbe_hw *hw)
 {
@@ -2113,6 +2114,9 @@ s32 ngbe_init_shared_code(struct ngbe_hw *hw)
 	case ngbe_mac_em:
 		ngbe_init_ops_pf(hw);
 		break;
+	case ngbe_mac_em_vf:
+		ngbe_init_ops_vf(hw);
+		break;
 	default:
 		status = NGBE_ERR_DEVICE_NOT_SUPPORTED;
 		break;
drivers/net/ngbe/base/ngbe_vf.c new file +26 -0
new file mode 100644
index 0000000000..91b8d1bbe2
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#include "ngbe_type.h"
+#include "ngbe_vf.h"
+
+/**
+ *  ngbe_init_ops_vf - Initialize the pointers for vf
+ *  @hw: pointer to hardware structure
+ *
+ *  This will assign function pointers, adapter-specific functions can
+ *  override the assignment of generic function pointers by assigning
+ *  their own adapter-specific function pointers.
+ *  Does not touch the hardware.
+ **/
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mac_info *mac = &hw->mac;
+
+	mac->max_tx_queues = 1;
+	mac->max_rx_queues = 1;
+
+	return 0;
+}
drivers/net/ngbe/base/ngbe_vf.h new file +13 -0
new file mode 100644
index 0000000000..7982ea231e
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2025 Beijing WangXun Technology Co., Ltd.
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _NGBE_VF_H_
+#define _NGBE_VF_H_
+
+#include "ngbe_type.h"
+
+s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+
+#endif /* __NGBE_VF_H__ */
drivers/net/ngbe/meson.build +1 -0
index 402cea1c13..f4f8f7ee79 100644
@@ -15,6 +15,7 @@ sources = files(
         'ngbe_ptypes.c',
         'ngbe_pf.c',
         'ngbe_rxtx.c',
+        'ngbe_ethdev_vf.c',
 )
 
 deps += ['hash']
drivers/net/ngbe/ngbe_ethdev_vf.c new file +163 -0

163 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#53 lore raw

PATCH v4 2/15 net/ngbe: add support for PF-VF mailbox interface

In reply to Zaiyu Wang

Add basic code of PF-VF mailbox implementation to serve the communication between VF and PF devices.

---
 drivers/net/ngbe/base/ngbe_mbx.c  | 338 ++++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_mbx.h  |  29 +++
 drivers/net/ngbe/base/ngbe_type.h |   7 +
 drivers/net/ngbe/base/ngbe_vf.c   |  56 +++++
 drivers/net/ngbe/base/ngbe_vf.h   |   1 +
 5 files changed, 431 insertions(+)
drivers/net/ngbe/base/ngbe_mbx.c +338 -0
index bc0adbb3ec..a96a4aced7 100644
@@ -109,6 +109,344 @@ s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id)
 	return ret_val;
 }
 
+/**
+ *  ngbe_poll_for_msg - Wait for message notification
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification
+ **/
+STATIC s32 ngbe_poll_for_msg(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_msg)
+		goto out;
+
+	while (countdown && mbx->check_for_msg(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox message timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_poll_for_ack - Wait for message acknowledgment
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message acknowledgment
+ **/
+STATIC s32 ngbe_poll_for_ack(struct ngbe_hw *hw, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	int countdown = mbx->timeout;
+
+	if (!countdown || !mbx->check_for_ack)
+		goto out;
+
+	while (countdown && mbx->check_for_ack(hw, mbx_id)) {
+		countdown--;
+		if (!countdown)
+			break;
+		usec_delay(mbx->usec_delay);
+	}
+
+	if (countdown == 0)
+		DEBUGOUT("Polling for VF%d mailbox ack timedout", mbx_id);
+
+out:
+	return countdown ? 0 : NGBE_ERR_MBX;
+}
+
+/**
+ *  ngbe_read_posted_mbx - Wait for message notification and receive message
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully received a message notification and
+ *  copied it into the receive buffer.
+ **/
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (!mbx->read)
+		goto out;
+
+	ret_val = ngbe_poll_for_msg(hw, mbx_id);
+
+	/* if ack received read message, otherwise we timed out */
+	if (!ret_val)
+		ret_val = mbx->read(hw, msg, size, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_posted_mbx - Write a message to the mailbox, wait for ack
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer and
+ *  received an ack to that message within delay * timeout period
+ **/
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size,
+			   u16 mbx_id)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* exit if either we can't write or there isn't a defined timeout */
+	if (!mbx->write || !mbx->timeout)
+		goto out;
+
+	/* send msg */
+	ret_val = mbx->write(hw, msg, size, mbx_id);
+
+	/* if msg sent wait until we receive an ack */
+	if (!ret_val)
+		ret_val = ngbe_poll_for_ack(hw, mbx_id);
+out:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_v2p_mailbox - read v2p mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  This function is used to read the v2p mailbox without losing the read to
+ *  clear status bits.
+ **/
+STATIC u32 ngbe_read_v2p_mailbox(struct ngbe_hw *hw)
+{
+	u32 v2p_mailbox = rd32(hw, NGBE_VFMBCTL);
+
+	v2p_mailbox |= hw->mbx.v2p_mailbox;
+	hw->mbx.v2p_mailbox |= v2p_mailbox & NGBE_VFMBCTL_R2C_BITS;
+
+	return v2p_mailbox;
+}
+
+/**
+ *  ngbe_check_for_bit_vf - Determine if a status bit was set
+ *  @hw: pointer to the HW structure
+ *  @mask: bitmask for bits to be tested and cleared
+ *
+ *  This function is used to check for the read to clear bits within
+ *  the V2P mailbox.
+ **/
+STATIC s32 ngbe_check_for_bit_vf(struct ngbe_hw *hw, u32 mask)
+{
+	u32 v2p_mailbox = ngbe_read_v2p_mailbox(hw);
+	s32 ret_val = NGBE_ERR_MBX;
+
+	if (v2p_mailbox & mask)
+		ret_val = 0;
+
+	hw->mbx.v2p_mailbox &= ~mask;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_msg_vf - checks to see if the PF has sent mail
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the Status bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFSTS)) {
+		ret_val = 0;
+		hw->mbx.stats.reqs++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_ack_vf - checks to see if the PF has ACK'd
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns SUCCESS if the PF has set the ACK bit or else ERR_MBX
+ **/
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, NGBE_VFMBCTL_PFACK)) {
+		ret_val = 0;
+		hw->mbx.stats.acks++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_check_for_rst_vf - checks to see if the PF has reset
+ *  @hw: pointer to the HW structure
+ *  @mbx_id: id of mailbox to check
+ *
+ *  returns true if the PF has set the reset done bit or else false
+ **/
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	if (!ngbe_check_for_bit_vf(hw, (NGBE_VFMBCTL_RSTD |
+	    NGBE_VFMBCTL_RSTI))) {
+		ret_val = 0;
+		hw->mbx.stats.rsts++;
+	}
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_obtain_mbx_lock_vf - obtain mailbox lock
+ *  @hw: pointer to the HW structure
+ *
+ *  return SUCCESS if we obtained the mailbox lock
+ **/
+STATIC s32 ngbe_obtain_mbx_lock_vf(struct ngbe_hw *hw)
+{
+	s32 ret_val = NGBE_ERR_MBX;
+
+	/* Take ownership of the buffer */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_VFU);
+
+	/* reserve mailbox for vf use */
+	if (ngbe_read_v2p_mailbox(hw) & NGBE_VFMBCTL_VFU)
+		ret_val = 0;
+
+	return ret_val;
+}
+
+/**
+ *  ngbe_write_mbx_vf - Write a message to the mailbox
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to write
+ *
+ *  returns SUCCESS if it successfully copied message into the buffer
+ **/
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			      u16 mbx_id)
+{
+	s32 ret_val;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_write;
+
+	/* flush msg and acks as we are overwriting the message buffer */
+	ngbe_check_for_msg_vf(hw, 0);
+	ngbe_check_for_ack_vf(hw, 0);
+
+	/* copy the caller specified message to the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		wr32a(hw, NGBE_VFMBX, i, msg[i]);
+
+	/* update stats */
+	hw->mbx.stats.msgs_tx++;
+
+	/* Drop VFU and interrupt the PF to tell it a message has been sent */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_REQ);
+
+out_no_write:
+	return ret_val;
+}
+
+/**
+ *  ngbe_read_mbx_vf - Reads a message from the inbox intended for vf
+ *  @hw: pointer to the HW structure
+ *  @msg: The message buffer
+ *  @size: Length of buffer
+ *  @mbx_id: id of mailbox to read
+ *
+ *  returns SUCCESS if it successfully read message from buffer
+ **/
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size,
+			     u16 mbx_id)
+{
+	s32 ret_val = 0;
+	u16 i;
+
+	UNREFERENCED_PARAMETER(mbx_id);
+
+	/* lock the mailbox to prevent pf/vf race condition */
+	ret_val = ngbe_obtain_mbx_lock_vf(hw);
+	if (ret_val)
+		goto out_no_read;
+
+	/* copy the message from the mailbox memory buffer */
+	for (i = 0; i < size; i++)
+		msg[i] = rd32a(hw, NGBE_VFMBX, i);
+
+	/* Acknowledge receipt and release mailbox, then we're done */
+	wr32(hw, NGBE_VFMBCTL, NGBE_VFMBCTL_ACK);
+
+	/* update stats */
+	hw->mbx.stats.msgs_rx++;
+
+out_no_read:
+	return ret_val;
+}
+
+/**
+ *  ngbe_init_mbx_params_vf - set initial values for vf mailbox
+ *  @hw: pointer to the HW structure
+ *
+ *  Initializes the hw->mbx struct to correct values for vf mailbox
+ */
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw)
+{
+	struct ngbe_mbx_info *mbx = &hw->mbx;
+
+	/* start mailbox as timed out and let the reset_hw call set the timeout
+	 * value to begin communications
+	 */
+	mbx->timeout = 0;
+	mbx->usec_delay = NGBE_VF_MBX_INIT_DELAY;
+
+	mbx->size = NGBE_P2VMBX_SIZE;
+
+	mbx->stats.msgs_tx = 0;
+	mbx->stats.msgs_rx = 0;
+	mbx->stats.reqs = 0;
+	mbx->stats.acks = 0;
+	mbx->stats.rsts = 0;
+}
+
 STATIC s32 ngbe_check_for_bit_pf(struct ngbe_hw *hw, u32 mask)
 {
 	u32 mbvficr = rd32(hw, NGBE_MBVFICR);
drivers/net/ngbe/base/ngbe_mbx.h +29 -0
index d47da2718c..83561fd4cf 100644
@@ -73,11 +73,34 @@ enum ngbevf_xcast_modes {
 
 /* length of permanent address message returned from PF */
 #define NGBE_VF_PERMADDR_MSG_LEN	4
+/* word in permanent address message with the current multicast type */
+#define NGBE_VF_MC_TYPE_WORD		3
+
+#define NGBE_PF_CONTROL_MSG		0x0100 /* PF control message */
+
+/* mailbox API, version 2.0 VF requests */
+#define NGBE_VF_API_NEGOTIATE		0x08 /* negotiate API version */
+#define NGBE_VF_GET_QUEUES		0x09 /* get queue configuration */
+#define NGBE_VF_ENABLE_MACADDR		0x0A /* enable MAC address */
+#define NGBE_VF_DISABLE_MACADDR	0x0B /* disable MAC address */
+#define NGBE_VF_GET_MACADDRS		0x0C /* get all configured MAC addrs */
+#define NGBE_VF_SET_MCAST_PROMISC	0x0D /* enable multicast promiscuous */
+#define NGBE_VF_GET_MTU		0x0E /* get bounds on MTU */
+#define NGBE_VF_SET_MTU		0x0F /* set a specific MTU */
+
+/* mailbox API, version 2.0 PF requests */
+#define NGBE_PF_TRANSPARENT_VLAN	0x0101 /* enable transparent vlan */
+
+#define NGBE_VF_MBX_INIT_TIMEOUT	2000 /* number of retries on mailbox */
+#define NGBE_VF_MBX_INIT_DELAY		500  /* microseconds between retries */
 s32 ngbe_read_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_write_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_read_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_posted_mbx(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
 s32 ngbe_check_for_msg(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_ack(struct ngbe_hw *hw, u16 mbx_id);
 s32 ngbe_check_for_rst(struct ngbe_hw *hw, u16 mbx_id);
+void ngbe_init_mbx_params_vf(struct ngbe_hw *hw);
 void ngbe_init_mbx_params_pf(struct ngbe_hw *hw);
 
 s32 ngbe_read_mbx_pf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
@@ -86,4 +109,10 @@ s32 ngbe_check_for_msg_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_ack_pf(struct ngbe_hw *hw, u16 vf_number);
 s32 ngbe_check_for_rst_pf(struct ngbe_hw *hw, u16 vf_number);
 
+s32 ngbe_read_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_write_mbx_vf(struct ngbe_hw *hw, u32 *msg, u16 size, u16 mbx_id);
+s32 ngbe_check_for_msg_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_ack_vf(struct ngbe_hw *hw, u16 mbx_id);
+s32 ngbe_check_for_rst_vf(struct ngbe_hw *hw, u16 mbx_id);
+
 #endif /* _NGBE_MBX_H_ */
drivers/net/ngbe/base/ngbe_type.h +7 -0
index a987bbe25b..35ebb7208a 100644
@@ -311,6 +311,7 @@ struct ngbe_mac_info {
 	s32 (*enable_sec_rx_path)(struct ngbe_hw *hw);
 	s32 (*acquire_swfw_sync)(struct ngbe_hw *hw, u32 mask);
 	void (*release_swfw_sync)(struct ngbe_hw *hw, u32 mask);
+	s32 (*negotiate_api_version)(struct ngbe_hw *hw, int api);
 
 	/* Link */
 	s32 (*setup_link)(struct ngbe_hw *hw, u32 speed,
@@ -422,6 +423,10 @@ struct ngbe_mbx_info {
 	void (*init_params)(struct ngbe_hw *hw);
 	s32  (*read)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
 	s32  (*write)(struct ngbe_hw *hw, u32 *msg, u16 size, u16 vf_number);
+	s32  (*read_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
+	s32  (*write_posted)(struct ngbe_hw *hw, u32 *msg, u16 size,
+				u16 mbx_id);
 	s32  (*check_for_msg)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_ack)(struct ngbe_hw *hw, u16 mbx_id);
 	s32  (*check_for_rst)(struct ngbe_hw *hw, u16 mbx_id);
@@ -429,6 +434,7 @@ struct ngbe_mbx_info {
 	struct ngbe_mbx_stats stats;
 	u32 timeout;
 	u32 usec_delay;
+	u32 v2p_mailbox;
 	u16 size;
 };
 
@@ -458,6 +464,7 @@ struct ngbe_hw {
 	u8 port_id;
 	u8 revision_id;
 	bool adapter_stopped;
+	int api_version;
 	bool wol_enabled;
 	bool ncsi_enabled;
 	bool lldp_enabled;
drivers/net/ngbe/base/ngbe_vf.c +56 -0

73 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 7982ea231e..23e5b0d8a3 100644
@@ -9,5 +9,6 @@
 #include "ngbe_type.h"
 
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 
 #endif /* __NGBE_VF_H__ */
Signature · 1 line
2.21.0.windows.1
author
#54 lore raw

PATCH v4 3/15 net/ngbe: add hardware configuration code for VF device

In reply to Zaiyu Wang

Add basic hardware configure flow and device information statement.

---
 doc/guides/nics/features/ngbe_vf.ini |   7 +
 drivers/net/ngbe/base/ngbe_mbx.h     |   2 +
 drivers/net/ngbe/base/ngbe_type.h    |   5 +
 drivers/net/ngbe/base/ngbe_vf.c      | 235 +++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   9 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 114 +++++++++++++
 6 files changed, 372 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +7 -0
index 4da36e0085..53824a7c90 100644
@@ -4,6 +4,13 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+CRC offload          = P
+VLAN offload         = P
+QinQ offload         = P
+L3 checksum offload  = P
+L4 checksum offload  = P
+Inner L3 checksum    = P
+Inner L4 checksum    = P
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_mbx.h +2 -0
index 83561fd4cf..27e977737d 100644
@@ -57,6 +57,8 @@ enum ngbe_pfvf_api_rev {
 #define NGBE_VF_GET_RSS_KEY	0x0b    /* get RSS key */
 #define NGBE_VF_UPDATE_XCAST_MODE	0x0c
 
+#define NGBE_VF_BACKUP		0x8001 /* VF requests backup */
+
 /* mode choices for NGBE_VF_UPDATE_XCAST_MODE */
 enum ngbevf_xcast_modes {
 	NGBEVF_XCAST_MODE_NONE = 0,
drivers/net/ngbe/base/ngbe_type.h +5 -0
index 35ebb7208a..4fd7080847 100644
@@ -8,6 +8,9 @@
 
 #define NGBE_LINK_UP_TIME	90 /* 9.0 Seconds */
 
+#define NGBE_RX_HDR_SIZE	256
+#define NGBE_RX_BUF_SIZE	2048
+
 #define NGBE_FRAME_SIZE_MAX       (9728) /* Maximum frame size, +FCS */
 #define NGBE_FRAME_SIZE_DFT       (1518) /* Default frame size, +FCS */
 #define NGBE_NUM_POOL             (32)
@@ -17,6 +20,7 @@
 #define NGBE_MAX_QP               (8)
 #define NGBE_MAX_UTA              128
 
+#define NGBE_VF_INIT_TIMEOUT	200 /* Number of retries to clear RSTI */
 #define NGBE_PCI_MASTER_DISABLE_TIMEOUT	800
 #define NGBE_SPI_TIMEOUT	10000
 
@@ -480,6 +484,7 @@ struct ngbe_hw {
 	u32 q_tx_regs[8 * 4];
 	u32 gphy_efuse[2];
 	bool offset_loaded;
+	bool rx_loaded;
 	bool is_pf;
 	bool gpio_ctl;
 	bool lsc;
drivers/net/ngbe/base/ngbe_vf.c +235 -0

253 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +9 -0
index 23e5b0d8a3..da846dda45 100644
@@ -8,7 +8,16 @@
 
 #include "ngbe_type.h"
 
+#define NGBE_VF_MAX_TX_QUEUES	1
+#define NGBE_VF_MAX_RX_QUEUES	1
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
+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);
 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);
 
 #endif /* __NGBE_VF_H__ */
drivers/net/ngbe/ngbe_ethdev_vf.c +114 -0

161 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#55 lore raw

PATCH v4 4/15 net/ngbe: add promiscuous and allmulticast ops for VF device

In reply to Zaiyu Wang

Support to enable and disable promiscuous and allmulticast mode on VF device.

---
 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(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index 53824a7c90..ba12357255 100644
@@ -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
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 4fd7080847..29dcd5f912 100644
@@ -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);
drivers/net/ngbe/base/ngbe_vf.c +39 -0
index 7c8b082f97..ccf7148b9c 100644
@@ -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;
 
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index da846dda45..79891e8389 100644
@@ -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);
drivers/net/ngbe/ngbe_ethdev_vf.c +96 -0

119 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#56 lore raw

PATCH v4 5/15 net/ngbe: add set MTU ops for VF device

In reply to Zaiyu Wang

Support to update MTU for VF device.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_type.h    |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 24 +++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 36 ++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index ba12357255..f2f2ac3881 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
drivers/net/ngbe/base/ngbe_type.h +1 -0
index 29dcd5f912..f780b92efa 100644
@@ -352,6 +352,7 @@ struct ngbe_mac_info {
 	void (*set_vlan_anti_spoofing)(struct ngbe_hw *hw,
 					bool enable, int vf);
 	s32 (*update_xcast_mode)(struct ngbe_hw *hw, int xcast_mode);
+	s32 (*set_rlpml)(struct ngbe_hw *hw, u16 max_size);
 
 	/* Flow Control */
 	s32 (*fc_enable)(struct ngbe_hw *hw);
drivers/net/ngbe/base/ngbe_vf.c +24 -0
index ccf7148b9c..c0436c7b8a 100644
@@ -228,6 +228,29 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbevf_rlpml_set_vf - Set the maximum receive packet length
+ *  @hw: pointer to the HW structure
+ *  @max_size: value to assign to max frame size
+ **/
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size)
+{
+	u32 msgbuf[2];
+	s32 retval;
+
+	msgbuf[0] = NGBE_VF_SET_LPE;
+	msgbuf[1] = max_size;
+
+	retval = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (retval)
+		return retval;
+	if ((msgbuf[0] & NGBE_VF_SET_LPE) &&
+	    (msgbuf[0] & NGBE_VT_MSGTYPE_NACK))
+		return NGBE_ERR_MBX;
+
+	return 0;
+}
+
 /**
  *  ngbevf_negotiate_api_version - Negotiate supported API version
  *  @hw: pointer to the HW structure
@@ -339,6 +362,7 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
 	mac->max_rx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +1 -0
index 79891e8389..a64de9d332 100644
@@ -17,6 +17,7 @@ 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);
+s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 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);
drivers/net/ngbe/ngbe_ethdev_vf.c +36 -0
index 28000471b5..f53c17cc82 100644
@@ -269,6 +269,41 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+	struct ngbe_hw *hw;
+	uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+	struct rte_eth_dev_data *dev_data = dev->data;
+
+	hw = ngbe_dev_hw(dev);
+
+	if (mtu < RTE_ETHER_MIN_MTU ||
+			max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
+		return -EINVAL;
+
+	/* If device is started, refuse mtu that requires the support of
+	 * scattered packets when this feature has not been enabled before.
+	 */
+	if (dev_data->dev_started && !dev_data->scattered_rx &&
+	    (max_frame + 2 * RTE_VLAN_HLEN >
+	     dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
+		PMD_INIT_LOG(ERR, "Stop port first.");
+		return -EINVAL;
+	}
+
+	/*
+	 * When supported by the underlying PF driver, use the NGBE_VF_SET_MTU
+	 * request of the version 2.0 of the mailbox API.
+	 * For now, use the NGBE_VF_SET_LPE request of the version 1.0
+	 * of the mailbox API.
+	 */
+	if (ngbevf_rlpml_set_vf(hw, max_frame))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
 {
@@ -366,6 +401,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.mtu_set              = ngbevf_dev_set_mtu,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
author
#57 lore raw

PATCH v4 6/15 net/ngbe: add add/remove/set mac addr ops for VF device

In reply to Zaiyu Wang

Generate a random MAC address if none was assigned by PF during the initialization of VF device. And support to add and remove MAC address.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_type.h    |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  83 +++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   4 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 146 +++++++++++++++++++++++++++
 5 files changed, 235 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index f2f2ac3881..dcf3392e1f 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Unicast MAC filter   = Y
 MTU update           = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
drivers/net/ngbe/base/ngbe_type.h +1 -0
index f780b92efa..7a3b52ffd4 100644
@@ -335,6 +335,7 @@ struct ngbe_mac_info {
 	/* RAR */
 	s32 (*set_rar)(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 			  u32 enable_addr);
+	s32 (*set_uc_addr)(struct ngbe_hw *hw, u32 index, u8 *addr);
 	s32 (*clear_rar)(struct ngbe_hw *hw, u32 index);
 	s32 (*set_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
 	s32 (*clear_vmdq)(struct ngbe_hw *hw, u32 rar, u32 vmdq);
drivers/net/ngbe/base/ngbe_vf.c +83 -0

103 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +4 -0
index a64de9d332..3f328a0221 100644
@@ -16,6 +16,10 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
+		     u32 enable_addr);
+s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
drivers/net/ngbe/ngbe_ethdev_vf.c +146 -0

188 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#58 lore raw

PATCH v4 7/15 net/ngbe: add datapath init code for VF device

In reply to Zaiyu Wang

Add support for datapath init, including RX and TX unit init.

---
 doc/guides/nics/features/ngbe_vf.ini |   5 +
 doc/guides/nics/ngbe.rst             |  11 ++
 drivers/net/ngbe/ngbe_ethdev.h       |   6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  63 ++++++++
 drivers/net/ngbe/ngbe_rxtx.c         | 209 +++++++++++++++++++++++++++
 5 files changed, 294 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +5 -0
index dcf3392e1f..97d8547cdf 100644
@@ -6,6 +6,9 @@
 [Features]
 Unicast MAC filter   = Y
 MTU update           = Y
+Scattered Rx         = Y
+LRO                  = Y
+TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 CRC offload          = P
@@ -15,6 +18,8 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Rx descriptor status = Y
+Tx descriptor status = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
doc/guides/nics/ngbe.rst +11 -0
index e31600c95a..b002fa4c19 100644
@@ -42,6 +42,17 @@ Prerequisites
 Configuration
 -------------
 
+Compilation Options
+~~~~~~~~~~~~~~~~~~~
+
+The following build-time options may be enabled on build time using.
+
+``-Dc_args=`` meson argument (e.g. ``-Dc_args=-DRTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC``).
+
+- ``RTE_LIBRTE_NGBE_PF_DISABLE_STRIP_CRC`` (undefined by default)
+
+  Decide to enable or disable HW CRC in VF PMD.
+
 Dynamic Logging Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
drivers/net/ngbe/ngbe_ethdev.h +6 -0
index 7af58a57ac..37c6459f51 100644
@@ -241,6 +241,12 @@ int
 ngbe_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id,
 		      struct rte_eth_burst_mode *mode);
 
+int ngbevf_dev_rx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_tx_init(struct rte_eth_dev *dev);
+
+void ngbevf_dev_rxtx_start(struct rte_eth_dev *dev);
+
 uint16_t ngbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
 
drivers/net/ngbe/ngbe_ethdev_vf.c +63 -0

81 lines not on this page · raw message

drivers/net/ngbe/ngbe_rxtx.c +209 -0

215 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#59 lore raw

PATCH v4 8/15 net/ngbe: add VLAN related ops for VF device

In reply to Zaiyu Wang

Add support for VLAN filter, offload and strip set feature.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/base/ngbe_vf.c      |  33 +++++++-
 drivers/net/ngbe/base/ngbe_vf.h      |   2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 112 +++++++++++++++++++++++++++
 4 files changed, 147 insertions(+), 1 deletion(-)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 97d8547cdf..441bf3bded 100644
@@ -11,6 +11,7 @@ LRO                  = Y
 TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
+VLAN filter          = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
drivers/net/ngbe/base/ngbe_vf.c +32 -1
index 47fee7e14d..039f87423d 100644
@@ -262,6 +262,36 @@ s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode)
 	return 0;
 }
 
+/**
+ *  ngbe_set_vfta_vf - Set/Unset vlan filter table address
+ *  @hw: pointer to the HW structure
+ *  @vlan: 12 bit VLAN ID
+ *  @vind: unused by VF drivers
+ *  @vlan_on: if true then set bit, else clear bit
+ *  @vlvf_bypass: boolean flag indicating updating default pool is okay
+ *
+ *  Turn on/off specified VLAN in the VLAN filter table.
+ **/
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass)
+{
+	u32 msgbuf[2];
+	s32 ret_val;
+
+	UNREFERENCED_PARAMETER(vind, vlvf_bypass);
+
+	msgbuf[0] = NGBE_VF_SET_VLAN;
+	msgbuf[1] = vlan;
+	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
+	msgbuf[0] |= vlan_on << NGBE_VT_MSGINFO_SHIFT;
+
+	ret_val = ngbevf_write_msg_read_ack(hw, msgbuf, msgbuf, 2);
+	if (!ret_val && (msgbuf[0] & NGBE_VT_MSGTYPE_ACK))
+		return 0;
+
+	return ret_val | (msgbuf[0] & NGBE_VT_MSGTYPE_NACK);
+}
+
 /**
  * ngbe_get_mac_addr_vf - Read device MAC address
  * @hw: pointer to the HW structure
@@ -441,10 +471,11 @@ s32 ngbe_init_ops_vf(struct ngbe_hw *hw)
 	mac->get_mac_addr = ngbe_get_mac_addr_vf;
 	mac->negotiate_api_version = ngbevf_negotiate_api_version;
 
-	/* RAR, Multicast */
+	/* RAR, Multicast, VLAN */
 	mac->set_rar = ngbe_set_rar_vf;
 	mac->set_uc_addr = ngbevf_set_uc_addr_vf;
 	mac->update_xcast_mode = ngbevf_update_xcast_mode;
+	mac->set_vfta = ngbe_set_vfta_vf;
 	mac->set_rlpml = ngbevf_rlpml_set_vf;
 
 	mac->max_tx_queues = 1;
drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 3f328a0221..596f41dcb0 100644
@@ -21,6 +21,8 @@ s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
+s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
+		      bool vlan_on, bool vlvf_bypass);
 s32 ngbevf_rlpml_set_vf(struct ngbe_hw *hw, u16 max_size);
 int ngbevf_negotiate_api_version(struct ngbe_hw *hw, int api);
 int ngbevf_get_queues(struct ngbe_hw *hw, unsigned int *num_tcs,
drivers/net/ngbe/ngbe_ethdev_vf.c +112 -0

142 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#60 lore raw

PATCH v4 9/15 net/ngbe: add interrupt support for VF device

In reply to Zaiyu Wang

Add VF device interrupt handler, support to enable and disable RX queue interrupt, and configure misx interrupt.

---
 doc/guides/nics/features/ngbe_vf.ini |   1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 230 +++++++++++++++++++++++++++
 2 files changed, 231 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 441bf3bded..d6f2a1d726 100644
@@ -5,6 +5,7 @@
 ;
 [Features]
 Unicast MAC filter   = Y
+Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
 LRO                  = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +230 -0

298 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#61 lore raw

PATCH v4 10/15 net/ngbe: add link update ops for VF device

In reply to Zaiyu Wang

Add support to check link feature for VF device, including link speed, duplex mode and link state.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 96 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  2 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    |  9 +++
 4 files changed, 108 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index d6f2a1d726..8e66565e6a 100644
@@ -4,6 +4,7 @@
 ; Refer to default.ini for the full list of available PMD features.
 ;
 [Features]
+Link status          = Y
 Unicast MAC filter   = Y
 Rx interrupt         = Y
 MTU update           = Y
drivers/net/ngbe/base/ngbe_vf.c +96 -0

108 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +2 -0
index 596f41dcb0..5cf225dd35 100644
@@ -17,6 +17,8 @@ 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 ngbe_get_mac_addr_vf(struct ngbe_hw *hw, u8 *mac_addr);
+s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
+			    bool *link_up, bool autoneg_wait_to_complete);
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
drivers/net/ngbe/ngbe_ethdev_vf.c +9 -0
index e1ba8b02d2..01e9d5d8ee 100644
@@ -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_link_update(struct rte_eth_dev *dev,
+				   int wait_to_complete);
 static void ngbevf_intr_disable(struct rte_eth_dev *dev);
 static void ngbevf_intr_enable(struct rte_eth_dev *dev);
 static int ngbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
@@ -345,6 +347,12 @@ ngbevf_dev_info_get(struct rte_eth_dev *dev,
 	return 0;
 }
 
+static int
+ngbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
+{
+	return ngbe_dev_link_update_share(dev, wait_to_complete);
+}
+
 static void
 ngbevf_intr_disable(struct rte_eth_dev *dev)
 {
@@ -939,6 +947,7 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.link_update          = ngbevf_dev_link_update,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
Signature · 1 line
2.21.0.windows.1
author
#62 lore raw

PATCH v4 11/15 net/ngbe: add stats and xstats ops for VF device

In reply to Zaiyu Wang

Add support to get stats and extended stats by reading hardware registers.

---
 doc/guides/nics/features/ngbe_vf.ini |   2 +
 drivers/net/ngbe/base/ngbe_vf.h      |  32 +++++++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 138 +++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +2 -0
index 8e66565e6a..11a9105abc 100644
@@ -23,6 +23,8 @@ Inner L3 checksum    = P
 Inner L4 checksum    = P
 Rx descriptor status = Y
 Tx descriptor status = Y
+Basic stats          = Y
+Extended stats       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/base/ngbe_vf.h +32 -0
index 5cf225dd35..abe1655f8e 100644
@@ -11,6 +11,38 @@
 #define NGBE_VF_MAX_TX_QUEUES	1
 #define NGBE_VF_MAX_RX_QUEUES	1
 
+struct ngbevf_hw_stats {
+	u64 base_vfgprc;
+	u64 base_vfgptc;
+	u64 base_vfgorc;
+	u64 base_vfgotc;
+	u64 base_vfmprc;
+
+	u64 last_vfgprc;
+	u64 last_vfgptc;
+	u64 last_vfgorc;
+	u64 last_vfgotc;
+	u64 last_vfmprc;
+	u64 last_vfbprc;
+	u64 last_vfmptc;
+	u64 last_vfbptc;
+
+	u64 vfgprc;
+	u64 vfgptc;
+	u64 vfgorc;
+	u64 vfgotc;
+	u64 vfmprc;
+	u64 vfbprc;
+	u64 vfmptc;
+	u64 vfbptc;
+
+	u64 saved_reset_vfgprc;
+	u64 saved_reset_vfgptc;
+	u64 saved_reset_vfgorc;
+	u64 saved_reset_vfgotc;
+	u64 saved_reset_vfmprc;
+};
+
 s32 ngbe_init_ops_vf(struct ngbe_hw *hw);
 s32 ngbe_init_hw_vf(struct ngbe_hw *hw);
 s32 ngbe_start_hw_vf(struct ngbe_hw *hw);
drivers/net/ngbe/ngbe_ethdev_vf.c +138 -0

168 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#63 lore raw

PATCH v4 12/15 net/ngbe: add start/stop/reset/close ops for VF device

In reply to Zaiyu Wang

Add the complete configuration process for start/stop/reset/close ops, so that applications can enable the device correctly.

---
 drivers/net/ngbe/ngbe_ethdev_vf.c | 170 +++++++++++++++++++++++++++++-
 1 file changed, 169 insertions(+), 1 deletion(-)
drivers/net/ngbe/ngbe_ethdev_vf.c +169 -1
index 93d801a1f3..e0e5950672 100644
@@ -553,12 +553,151 @@ ngbevf_dev_configure(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+ngbevf_dev_start(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	uint32_t intr_vector = 0;
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	int err, mask = 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	err = hw->mac.reset_hw(hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
+		return err;
+	}
+	hw->mac.get_link_status = true;
+
+	/* negotiate mailbox API version to use with the PF. */
+	ngbevf_negotiate_api(hw);
+
+	ngbevf_dev_tx_init(dev);
+
+	/* This can fail when allocating mbufs for descriptor rings */
+	err = ngbevf_dev_rx_init(dev);
+
+	/**
+	 * In this case, reuses the MAC address assigned by VF
+	 * initialization.
+	 */
+	if (err != 0 && err != NGBE_ERR_INVALID_MAC_ADDR) {
+		PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	/* Set vfta */
+	ngbevf_set_vfta_all(dev, 1);
+
+	/* Set HW strip */
+	mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
+		RTE_ETH_VLAN_EXTEND_MASK;
+	err = ngbevf_vlan_offload_config(dev, mask);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
+		ngbe_dev_clear_queues(dev);
+		return err;
+	}
+
+	ngbevf_dev_rxtx_start(dev);
+
+	/* check and configure queue intr-vector mapping */
+	if (rte_intr_cap_multiple(intr_handle) &&
+	    dev->data->dev_conf.intr_conf.rxq) {
+		/* According to datasheet, only vector 0/1/2 can be used,
+		 * now only one vector is used for Rx queue
+		 */
+		intr_vector = 1;
+		if (rte_intr_efd_enable(intr_handle, intr_vector))
+			return -1;
+	}
+
+	if (rte_intr_dp_is_en(intr_handle)) {
+		if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
+						   dev->data->nb_rx_queues)) {
+			PMD_INIT_LOG(ERR,
+				     "Failed to allocate %d rx_queues intr_vec",
+				     dev->data->nb_rx_queues);
+			return -ENOMEM;
+		}
+	}
+
+	ngbevf_configure_msix(dev);
+
+	/* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
+	 * is mapped to VFIO vector 0 in eth_ngbevf_dev_init( ).
+	 * If previous VFIO interrupt mapping setting in eth_ngbevf_dev_init( )
+	 * is not cleared, it will fail when following rte_intr_enable( ) tries
+	 * to map Rx queue interrupt to other VFIO vectors.
+	 * So clear uio/vfio intr/evevnfd first to avoid failure.
+	 */
+	rte_intr_disable(intr_handle);
+
+	rte_intr_enable(intr_handle);
+
+	/* Re-enable interrupt for VF */
+	ngbevf_intr_enable(dev);
+
+	/*
+	 * Update link status right before return, because it may
+	 * start link configuration process in a separate thread.
+	 */
+	ngbevf_dev_link_update(dev, 0);
+
+	hw->adapter_stopped = false;
+
+	return 0;
+}
+
+static int
+ngbevf_dev_stop(struct rte_eth_dev *dev)
+{
+	struct ngbe_hw *hw = ngbe_dev_hw(dev);
+	struct ngbe_adapter *adapter = ngbe_dev_adapter(dev);
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
+	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+
+	if (hw->adapter_stopped)
+		return 0;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ngbevf_intr_disable(dev);
+
+	hw->adapter_stopped = 1;
+	hw->mac.stop_hw(hw);
+
+	/*
+	 * Clear what we set, but we still keep shadow_vfta to
+	 * restore after device starts
+	 */
+	ngbevf_set_vfta_all(dev, 0);
+
+	/* Clear stored conf */
+	dev->data->scattered_rx = 0;
+
+	ngbe_dev_clear_queues(dev);
+
+	/* Clean datapath event and queue/vec mapping */
+	rte_intr_efd_disable(intr_handle);
+	rte_intr_vec_list_free(intr_handle);
+
+	adapter->rss_reta_updated = 0;
+
+	return 0;
+}
+
 static int
 ngbevf_dev_close(struct rte_eth_dev *dev)
 {
 	struct ngbe_hw *hw = ngbe_dev_hw(dev);
 	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
 	struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
+	int ret;
 
 	PMD_INIT_FUNC_TRACE();
 	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
@@ -566,6 +705,10 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 
 	hw->mac.reset_hw(hw);
 
+	ret = ngbevf_dev_stop(dev);
+
+	ngbe_dev_free_queues(dev);
+
 	/**
 	 * Remove the VF MAC address ro ensure
 	 * that the VF traffic goes to the PF
@@ -586,7 +729,24 @@ ngbevf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     ngbevf_dev_interrupt_handler, dev);
 
-	return 0;
+	return ret;
+}
+
+/*
+ * Reset VF device
+ */
+static int
+ngbevf_dev_reset(struct rte_eth_dev *dev)
+{
+	int ret;
+
+	ret = eth_ngbevf_dev_uninit(dev);
+	if (ret)
+		return ret;
+
+	ret = eth_ngbevf_dev_init(dev);
+
+	return ret;
 }
 
 static void ngbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
@@ -1080,12 +1240,16 @@ ngbevf_dev_interrupt_handler(void *param)
  */
 static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.dev_configure        = ngbevf_dev_configure,
+	.dev_start            = ngbevf_dev_start,
+	.dev_stop             = ngbevf_dev_stop,
 	.link_update          = ngbevf_dev_link_update,
 	.stats_get            = ngbevf_dev_stats_get,
 	.xstats_get           = ngbevf_dev_xstats_get,
 	.stats_reset          = ngbevf_dev_stats_reset,
 	.xstats_reset         = ngbevf_dev_stats_reset,
 	.xstats_get_names     = ngbevf_dev_xstats_get_names,
+	.dev_close            = ngbevf_dev_close,
+	.dev_reset	      = ngbevf_dev_reset,
 	.promiscuous_enable   = ngbevf_dev_promiscuous_enable,
 	.promiscuous_disable  = ngbevf_dev_promiscuous_disable,
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
@@ -1095,6 +1259,10 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
 	.vlan_offload_set     = ngbevf_vlan_offload_set,
+	.rx_queue_setup       = ngbe_dev_rx_queue_setup,
+	.rx_queue_release     = ngbe_dev_rx_queue_release,
+	.tx_queue_setup       = ngbe_dev_tx_queue_setup,
+	.tx_queue_release     = ngbe_dev_tx_queue_release,
 	.rx_queue_intr_enable = ngbevf_dev_rx_queue_intr_enable,
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
Signature · 1 line
2.21.0.windows.1
author
#64 lore raw

PATCH v4 13/15 net/ngbe: add multicast MAC filter ops for VF device

In reply to Zaiyu Wang

Add support to update multicast MAC filter.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/base/ngbe_vf.c      | 81 ++++++++++++++++++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |  3 ++
 3 files changed, 85 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 11a9105abc..3c54047fd8 100644
@@ -6,6 +6,7 @@
 [Features]
 Link status          = Y
 Unicast MAC filter   = Y
+Multicast MAC filter = Y
 Rx interrupt         = Y
 MTU update           = Y
 Scattered Rx         = Y
drivers/net/ngbe/base/ngbe_vf.c +81 -0

99 lines not on this page · raw message

drivers/net/ngbe/base/ngbe_vf.h +3 -0
index abe1655f8e..5621ca49cb 100644
@@ -54,6 +54,9 @@ s32 ngbe_check_mac_link_vf(struct ngbe_hw *hw, u32 *speed,
 s32 ngbe_set_rar_vf(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
 		     u32 enable_addr);
 s32 ngbevf_set_uc_addr_vf(struct ngbe_hw *hw, u32 index, u8 *addr);
+s32 ngbe_update_mc_addr_list_vf(struct ngbe_hw *hw, u8 *mc_addr_list,
+				 u32 mc_addr_count, ngbe_mc_addr_itr next,
+				 bool clear);
 s32 ngbevf_update_xcast_mode(struct ngbe_hw *hw, int xcast_mode);
 s32 ngbe_set_vfta_vf(struct ngbe_hw *hw, u32 vlan, u32 vind,
 		      bool vlan_on, bool vlvf_bypass);
Signature · 1 line
2.21.0.windows.1
author
#65 lore raw

PATCH v4 14/15 net/ngbe: add dump registers ops for VF device

In reply to Zaiyu Wang

Add support to dump registers for VF device. Currently we only support a small number of registers. More registers will be added as needed.

---
 doc/guides/nics/features/ngbe_vf.ini |  1 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 73 ++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +1 -0
index 3c54047fd8..745ef4dc32 100644
@@ -26,6 +26,7 @@ Rx descriptor status = Y
 Tx descriptor status = Y
 Basic stats          = Y
 Extended stats       = Y
+Registers dump       = Y
 Multiprocess aware   = Y
 Linux                = Y
 ARMv8                = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +73 -0

91 lines not on this page · raw message

Signature · 1 line
2.21.0.windows.1
author
#66 lore raw

PATCH v4 15/15 net/ngbe: add some ops which PF has implemented

In reply to Zaiyu Wang

Some RXTX operations like queue setup and release, packet type get, and Tx done cleanup have been supported on PF device. There are ops functions directly added.

---
 doc/guides/nics/features/ngbe_vf.ini | 3 +++
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 5 +++++
 2 files changed, 8 insertions(+)
doc/guides/nics/features/ngbe_vf.ini +3 -0
index 745ef4dc32..5207d56dbf 100644
@@ -15,6 +15,7 @@ TSO                  = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 VLAN filter          = Y
+Inline crypto        = Y
 CRC offload          = P
 VLAN offload         = P
 QinQ offload         = P
@@ -22,8 +23,10 @@ L3 checksum offload  = P
 L4 checksum offload  = P
 Inner L3 checksum    = P
 Inner L4 checksum    = P
+Packet type parsing  = Y
 Rx descriptor status = Y
 Tx descriptor status = Y
+Free Tx mbuf on demand = Y
 Basic stats          = Y
 Extended stats       = Y
 Registers dump       = Y
drivers/net/ngbe/ngbe_ethdev_vf.c +5 -0
index bbd9fea328..5d68f1602d 100644
@@ -1327,6 +1327,7 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.allmulticast_enable  = ngbevf_dev_allmulticast_enable,
 	.allmulticast_disable = ngbevf_dev_allmulticast_disable,
 	.dev_infos_get        = ngbevf_dev_info_get,
+	.dev_supported_ptypes_get = ngbe_dev_supported_ptypes_get,
 	.mtu_set              = ngbevf_dev_set_mtu,
 	.vlan_filter_set      = ngbevf_vlan_filter_set,
 	.vlan_strip_queue_set = ngbevf_vlan_strip_queue_set,
@@ -1339,8 +1340,12 @@ static const struct eth_dev_ops ngbevf_eth_dev_ops = {
 	.rx_queue_intr_disable = ngbevf_dev_rx_queue_intr_disable,
 	.mac_addr_add         = ngbevf_add_mac_addr,
 	.mac_addr_remove      = ngbevf_remove_mac_addr,
+	.set_mc_addr_list     = ngbe_dev_set_mc_addr_list,
+	.rxq_info_get         = ngbe_rxq_info_get,
+	.txq_info_get         = ngbe_txq_info_get,
 	.mac_addr_set         = ngbevf_set_default_mac_addr,
 	.get_reg              = ngbevf_get_regs,
+	.tx_done_cleanup      = ngbe_dev_tx_done_cleanup,
 };
 
 RTE_PMD_REGISTER_PCI(net_ngbe_vf, rte_ngbevf_pmd);
Signature · 1 line
2.21.0.windows.1
#67 lore raw
In reply to Zaiyu Wang
Quoted 43 lines · On Mon, 20 Jan 2025 17:42:26 +0800 Zaiyu Wang <[email protected]> wrote:

This patch adds support to VF device for ngbe PMD.

---
v2:
- update description of patch content
- fix build issue
- formatting and cleanup
---
v3:
- fix Intel-compilation error
---
v4:
- fix to add Line Feed at the end of files
---

Zaiyu Wang (15):
net/ngbe: add ethdev probe and remove for VF device net/ngbe: add support for PF-VF mailbox interface net/ngbe: add hardware configuration code for VF device net/ngbe: add promiscuous and allmulticast ops for VF device net/ngbe: add set MTU ops for VF device
net/ngbe: add add/remove/set mac addr ops for VF device net/ngbe: add datapath init code for VF device net/ngbe: add VLAN related ops for VF device net/ngbe: add interrupt support for VF device net/ngbe: add link update ops for VF device net/ngbe: add stats and xstats ops for VF device net/ngbe: add start/stop/reset/close ops for VF device net/ngbe: add multicast MAC filter ops for VF device net/ngbe: add dump registers ops for VF device net/ngbe: add some ops which PF has implemented

 doc/guides/nics/features/ngbe_vf.ini |   37 +
 doc/guides/nics/ngbe.rst             |   11 +
 drivers/net/ngbe/base/meson.build    |    1 +
 drivers/net/ngbe/base/ngbe.h         |    1 +
 drivers/net/ngbe/base/ngbe_hw.c      |    4 +
 drivers/net/ngbe/base/ngbe_mbx.c     |  338 +++++++
 drivers/net/ngbe/base/ngbe_mbx.h     |   31 +
 drivers/net/ngbe/base/ngbe_type.h    |   15 +
 drivers/net/ngbe/base/ngbe_vf.c      |  671 +++++++++++++
 drivers/net/ngbe/base/ngbe_vf.h      |   68 ++
 drivers/net/ngbe/meson.build         |    1 +
Quoted 9 lines
 drivers/net/ngbe/ngbe_ethdev.h       |    6 +
 drivers/net/ngbe/ngbe_ethdev_vf.c    | 1353 ++++++++++++++++++++++++++
 drivers/net/ngbe/ngbe_rxtx.c         |  209 ++++
 14 files changed, 2746 insertions(+)
 create mode 100644 doc/guides/nics/features/ngbe_vf.ini
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.c
 create mode 100644 drivers/net/ngbe/base/ngbe_vf.h
 create mode 100644 drivers/net/ngbe/ngbe_ethdev_vf.c

Pending in next-net branch.
Could you please add a short release note in a follow on patch?