All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernard Iremonger <bernard.iremonger@intel.com>
To: rahul.r.shah@intel.com, wenzhuo.lu@intel.com, dev@dpdk.org
Cc: Bernard Iremonger <bernard.iremonger@intel.com>,
	azelezniak <alexz@att.com>
Subject: [RFC PATCH 4/5] net/ixgbe: add functions for VF management
Date: Thu, 18 Aug 2016 14:48:44 +0100	[thread overview]
Message-ID: <1471528125-26357-5-git-send-email-bernard.iremonger@intel.com> (raw)
In-Reply-To: <1471528125-26357-1-git-send-email-bernard.iremonger@intel.com>

Add new functions to configure and manage VF's on a Niantic NIC.

add ixgbe_vf_ping function.
add ixgbe_set_vf_vlan_anti_spoof function.
add ixgbe_set_vf_mac_anti_spoof function.

Signed-off-by: azelezniak <alexz@att.com>

add ixgbe_set_vf_vlan_strip function
add ixgbe_set_vf_vlan_insert function.
add ixgbe_set_tx_loopback function.
add ixgbe_set_all_queues_drop function.
add ixgbe_set_vf_split_drop_en function.
add ixgbe_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 179 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 179 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index d478a15..3b0ee82 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -240,6 +240,8 @@ static void ixgbe_add_rar(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
 static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
 static void ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
 					   struct ether_addr *mac_addr);
+static int ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf,
+				struct ether_addr *mac_addr);
 static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
 
 /* For Virtual Function support */
@@ -280,6 +282,19 @@ static int ixgbe_set_pool_rx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on)
 static int ixgbe_set_pool_tx(struct rte_eth_dev *dev, uint16_t pool, uint8_t on);
 static int ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
 		uint64_t pool_mask, uint8_t vlan_on);
+static void ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+		uint16_t vf, uint8_t on);
+static void ixgbe_set_vf_mac_anti_spoof(struct rte_eth_dev *dev,
+		uint16_t vf, uint8_t on);
+static int ixgbe_vf_ping(struct rte_eth_dev *dev, int32_t vf);
+static void ixgbe_set_vf_vlan_strip(struct rte_eth_dev *dev,
+		int on, uint16_t queues_per_pool);
+static void ixgbe_set_vf_vlan_insert(struct rte_eth_dev *dev, uint16_t vf,
+		int vlan);
+static void ixgbe_set_tx_loopback(struct rte_eth_dev *dev, int on);
+static void ixgbe_set_all_queues_drop_en(struct rte_eth_dev *dev, int state);
+static void ixgbe_set_vf_split_drop_en(struct rte_eth_dev *dev, uint16_t vf,
+		int state);
 static int ixgbe_mirror_rule_set(struct rte_eth_dev *dev,
 		struct rte_eth_mirror_conf *mirror_conf,
 		uint8_t rule_id, uint8_t on);
@@ -505,6 +520,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.mac_addr_add         = ixgbe_add_rar,
 	.mac_addr_remove      = ixgbe_remove_rar,
 	.mac_addr_set         = ixgbe_set_default_mac_addr,
+	.set_vf_mac_addr      = ixgbe_set_vf_mac_addr,
 	.uc_hash_table_set    = ixgbe_uc_hash_table_set,
 	.uc_all_hash_table_set  = ixgbe_uc_all_hash_table_set,
 	.mirror_rule_set      = ixgbe_mirror_rule_set,
@@ -513,6 +529,14 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
 	.set_vf_rx            = ixgbe_set_pool_rx,
 	.set_vf_tx            = ixgbe_set_pool_tx,
 	.set_vf_vlan_filter   = ixgbe_set_pool_vlan_filter,
+	.set_vf_vlan_anti_spoof  = ixgbe_set_vf_vlan_anti_spoof,
+	.set_vf_mac_anti_spoof   = ixgbe_set_vf_mac_anti_spoof,
+	.vf_ping              = ixgbe_vf_ping,
+	.set_vf_vlan_strip    = ixgbe_set_vf_vlan_strip,
+	.set_vf_vlan_insert   = ixgbe_set_vf_vlan_insert,
+	.set_tx_loopback      = ixgbe_set_tx_loopback,
+	.set_all_queues_drop_en = ixgbe_set_all_queues_drop_en,
+	.set_vf_split_drop_en = ixgbe_set_vf_split_drop_en,
 	.set_queue_rate_limit = ixgbe_set_queue_rate_limit,
 	.set_vf_rate_limit    = ixgbe_set_vf_rate_limit,
 	.reta_update          = ixgbe_dev_rss_reta_update,
@@ -4012,6 +4036,22 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 }
 
 static int
+ixgbe_set_vf_mac_addr(struct rte_eth_dev *dev, uint16_t vf, struct ether_addr *mac_addr)
+{
+	struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_vf_info *vfinfo =
+		*(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
+	int rar_entry = hw->mac.num_rar_entries - (vf + 1);
+	uint8_t *new_mac = (uint8_t *)(mac_addr);
+
+	if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
+		rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, ETHER_ADDR_LEN);
+		return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, IXGBE_RAH_AV);
+	}
+	return -1;
+}
+
+static int
 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
 	uint32_t hlreg0;
@@ -4315,6 +4355,16 @@ ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
 }
 
 static void
+ixgbe_set_vf_vlan_strip(struct rte_eth_dev *dev, int on,
+		uint16_t queues_per_pool)
+{
+	uint16_t q;
+
+	for (q = 0; q < queues_per_pool; q++)
+		ixgbevf_vlan_strip_queue_set(dev, q, on);
+}
+
+static void
 ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
 {
 	struct ixgbe_hw *hw =
@@ -4604,6 +4654,135 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
 	return ret;
 }
 
+static void
+ixgbe_set_vf_vlan_anti_spoof(struct rte_eth_dev *dev,
+			uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw =
+			IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	struct ixgbe_mac_info *mac = &hw->mac;
+
+	mac->ops.set_vlan_anti_spoofing(hw, on, vf);
+}
+
+static void
+ixgbe_set_vf_mac_anti_spoof(struct rte_eth_dev *dev,
+			uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	struct ixgbe_mac_info *mac = &hw->mac;
+
+	mac->ops.set_mac_anti_spoofing(hw, on, vf);
+}
+
+static int
+ixgbe_vf_ping(struct rte_eth_dev *dev, int32_t vf)
+{
+	int ret = 0;
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+	struct ixgbe_vf_info *vfinfo =
+		*IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
+
+	u32 ping;
+	int i;
+
+	for (i = 0; i < dev->pci_dev->max_vfs; i++) {
+		ping = IXGBE_PF_CONTROL_MSG;
+		if (vfinfo[i].clear_to_send)
+			ping |= IXGBE_VT_MSGTYPE_CTS;
+
+		/* ping every VF or only one specified */
+		if (vf < 0 || vf == i)
+			ixgbe_write_mbx(hw, &ping, 1, i);
+	}
+
+	return ret;
+}
+
+static void
+ixgbe_set_vf_vlan_insert(struct rte_eth_dev *dev, uint16_t vf, int vlan)
+{
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t ctrl;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf));
+	if (vlan) {
+		ctrl = vlan;
+		ctrl |= IXGBE_VMVIR_VLANA_DEFAULT;
+	} else {
+		ctrl = 0;
+	}
+
+	IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), ctrl);
+}
+
+static void
+ixgbe_set_tx_loopback(struct rte_eth_dev *dev, int on)
+{
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t ctrl;
+
+	PMD_INIT_FUNC_TRACE();
+
+	ctrl = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
+	/* enable or disable VMDQ loopback */
+	if (on)
+		ctrl |= IXGBE_PFDTXGSWC_VT_LBEN;
+	else
+		ctrl &= ~IXGBE_PFDTXGSWC_VT_LBEN;
+
+	IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, ctrl);
+}
+
+static void
+ixgbe_set_all_queues_drop_en(struct rte_eth_dev *dev, int state)
+{
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t reg_value;
+	int i;
+	int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
+
+	PMD_INIT_FUNC_TRACE();
+
+	for (i = 0; i <= num_queues; i++) {
+		reg_value = IXGBE_QDE_WRITE |
+				(i << IXGBE_QDE_IDX_SHIFT) |
+				(state & IXGBE_QDE_ENABLE);
+		IXGBE_WRITE_REG(hw, IXGBE_QDE, reg_value);
+	}
+}
+
+static void
+ixgbe_set_vf_split_drop_en(struct rte_eth_dev *dev, uint16_t vf, int state)
+{
+	struct ixgbe_hw *hw =
+		IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	uint32_t reg_value;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* only support VF's 0 to 63 */
+	if (vf > 63)
+		return;
+
+	reg_value = IXGBE_READ_REG(hw, IXGBE_SRRCTL(vf));
+	if (state)
+		reg_value |= IXGBE_SRRCTL_DROP_EN;
+	else
+		reg_value &= ~IXGBE_SRRCTL_DROP_EN;
+
+	IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(vf), reg_value);
+}
+
 #define IXGBE_MRCTL_VPME  0x01 /* Virtual Pool Mirroring. */
 #define IXGBE_MRCTL_UPME  0x02 /* Uplink Port Mirroring. */
 #define IXGBE_MRCTL_DPME  0x04 /* Downlink Port Mirroring. */
-- 
2.9.0

  parent reply	other threads:[~2016-08-18 13:48 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-18 13:48 [RFC PATCH 0/5] add API's for VF management Bernard Iremonger
2016-08-18 13:48 ` [RFC PATCH 1/5] librte_ether: add internal callback functions Bernard Iremonger
2016-08-18 13:48 ` [RFC PATCH 2/5] net/ixgbe: add callback to user app on VF to PF mbox msg Bernard Iremonger
2016-08-18 13:48 ` [RFC PATCH 3/5] librte_ether: add API's for VF management Bernard Iremonger
2016-08-18 13:48 ` Bernard Iremonger [this message]
2016-08-18 13:48 ` [RFC PATCH 5/5] app/test_pmd: add tests for new API's Bernard Iremonger
2016-08-26  9:10 ` [RFC PATCH v2 0/5] add API's for VF management Bernard Iremonger
2016-08-26  9:10   ` [RFC PATCH v2 1/5] librte_ether: add internal callback functions Bernard Iremonger
2016-09-09 14:10     ` Jerin Jacob
     [not found]       ` <3C0218D8B3DD114D8DBFE6B68141FBE3185F9FE7@MISOUT7MSGUSRDI.ITServices.sbc.com>
2016-09-13  8:45         ` Jerin Jacob
     [not found]           ` <3C0218D8B3DD114D8DBFE6B68141FBE3185FDCDC@MISOUT7MSGUSRDI.ITServices.sbc.com>
2016-09-14 11:28             ` Jerin Jacob
2016-09-22 11:25               ` Iremonger, Bernard
2016-10-03  8:58               ` Iremonger, Bernard
2016-08-26  9:10   ` [RFC PATCH v2 2/5] net/ixgbe: add callback to user app on VF to PF mbox msg Bernard Iremonger
2016-08-26  9:10   ` [RFC PATCH v2 3/5] librte_ether: add API's for VF management Bernard Iremonger
2016-09-09 14:22     ` Jerin Jacob
2016-09-12 16:28       ` Iremonger, Bernard
2016-09-13  9:24         ` Thomas Monjalon
2016-09-15 16:46           ` Iremonger, Bernard
2016-09-22 17:04             ` Thomas Monjalon
2016-09-23  9:20               ` Bruce Richardson
2016-09-23  9:36                 ` Thomas Monjalon
2016-09-23  9:53                   ` Richardson, Bruce
2016-09-23 13:15                     ` Thomas Monjalon
2016-09-23 17:02                       ` Iremonger, Bernard
2016-09-23 17:18                         ` Thomas Monjalon
2016-09-26 15:37                           ` Iremonger, Bernard
2016-09-26 16:59                             ` Thomas Monjalon
2016-09-27 10:31                               ` Iremonger, Bernard
2016-09-27 13:01                                 ` Bruce Richardson
2016-09-27 14:13                                   ` Iremonger, Bernard
2016-09-28 11:23                                     ` Ananyev, Konstantin
2016-09-28 12:31                                       ` Iremonger, Bernard
2016-09-28 13:01                                       ` Richardson, Bruce
2016-09-28 13:03                                       ` Thomas Monjalon
2016-09-28 13:26                                         ` Ananyev, Konstantin
2016-09-28 14:24                                           ` Thomas Monjalon
2016-09-28 14:30                                             ` Ananyev, Konstantin
2016-09-28 14:48                                               ` Iremonger, Bernard
2016-09-28 15:00                                                 ` Thomas Monjalon
2016-09-28 15:24                                                   ` Iremonger, Bernard
2016-09-28 14:59                                               ` Thomas Monjalon
2016-09-28 16:52                                                 ` Ananyev, Konstantin
2016-09-28 18:02                                                   ` Thomas Monjalon
2016-09-30  9:21                                                     ` Bruce Richardson
2016-09-23 10:34                   ` Bruce Richardson
2016-08-26  9:10   ` [RFC PATCH v2 4/5] net/ixgbe: add functions " Bernard Iremonger
2016-08-26  9:10   ` [RFC PATCH v2 5/5] app/test_pmd: add tests for new API's Bernard Iremonger
2016-09-11 12:35     ` Yuanhan Liu
2016-09-12 15:57       ` Iremonger, Bernard
2016-09-13  4:34         ` Yuanhan Liu
2016-09-13  8:38           ` Iremonger, Bernard
2016-09-13  8:42             ` Yuanhan Liu
2016-09-07  9:18   ` [RFC PATCH v2 0/5] add API's for VF management Pattan, Reshma
2016-09-09  8:49   ` Pattan, Reshma
2016-09-09 13:02     ` Thomas Monjalon
2016-09-16 11:05   ` [PATCH v3 0/3] " Bernard Iremonger
2016-09-16 11:05   ` [PATCH v3 1/3] librte_ether: " Bernard Iremonger
2016-09-16 11:05   ` [PATCH v3 2/3] net/ixgbe: add functions " Bernard Iremonger
2016-09-16 11:05   ` [PATCH v3 3/3] app/test_pmd: add tests for new API's Bernard Iremonger
2016-09-16 14:15   ` [PATCH v3 0/3] add API's for VF management Bernard Iremonger
2016-09-21 10:20     ` [PATCH v4 " Bernard Iremonger
2016-09-29 14:16       ` [PATCH v5 " Bernard Iremonger
2016-09-30 10:30         ` [PATCH v6 0/2] " Bernard Iremonger
2016-09-30 10:30         ` [PATCH v6 1/2] net/ixgbe: " Bernard Iremonger
2016-10-07 10:45           ` [PATCH v7 0/2] " Bernard Iremonger
2016-10-07 10:45           ` [PATCH v7 1/2] net/ixgbe: " Bernard Iremonger
2016-10-07 10:45           ` [PATCH v7 2/2] app/test_pmd: add tests for new API's Bernard Iremonger
2016-10-11 15:09             ` Ferruh Yigit
2016-10-11 15:41               ` Thomas Monjalon
2016-10-11 15:51                 ` Iremonger, Bernard
2016-10-11 16:32                   ` Thomas Monjalon
2016-10-11 16:35                     ` Iremonger, Bernard
2016-10-12  2:05                       ` De Lara Guarch, Pablo
2016-10-12 15:00                         ` Iremonger, Bernard
2016-09-30 10:30         ` [PATCH v6 " Bernard Iremonger
2016-09-29 14:16       ` [PATCH v5 1/3] librte_ether: add API for VF management Bernard Iremonger
2016-09-29 14:30         ` Thomas Monjalon
2016-09-29 15:16           ` Iremonger, Bernard
2016-09-29 16:19             ` Thomas Monjalon
2016-09-29 16:38               ` Iremonger, Bernard
2016-09-29 16:45                 ` Thomas Monjalon
2016-09-29 14:16       ` [PATCH v5 2/3] net/ixgbe: add API's " Bernard Iremonger
2016-09-29 16:11         ` Reshma Pattan
2016-09-29 16:32           ` Iremonger, Bernard
2016-09-29 16:16         ` Pattan, Reshma
2016-09-29 16:30           ` Iremonger, Bernard
2016-09-29 14:16       ` [PATCH v5 3/3] app/test_pmd: add tests for new API's Bernard Iremonger
2016-09-21 10:20     ` [PATCH v4 1/3] librte_ether: add API's for VF management Bernard Iremonger
2016-09-21 10:20     ` [PATCH v4 2/3] net/ixgbe: add functions " Bernard Iremonger
2016-09-21 10:20     ` [PATCH v4 3/3] app/test_pmd: add tests for new API's Bernard Iremonger
2016-09-16 14:15   ` [PATCH v3 1/3] librte_ether: add API's for VF management Bernard Iremonger
2016-09-16 14:15   ` [PATCH v3 2/3] net/ixgbe: add functions " Bernard Iremonger
2016-09-16 14:15   ` [PATCH v3 3/3] app/test_pmd: add tests for new API's Bernard Iremonger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471528125-26357-5-git-send-email-bernard.iremonger@intel.com \
    --to=bernard.iremonger@intel.com \
    --cc=alexz@att.com \
    --cc=dev@dpdk.org \
    --cc=rahul.r.shah@intel.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.