From: Or Gerlitz <ogerlitz@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Don Dutile <ddutile@redhat.com>,
Doug Ledford <dledford@redhat.com>,
Saeed Mahameed <saeedm@mellanox.com>,
Tal Alon <talal@mellanox.com>,
Hadar Har-Zion <hadarh@mellanox.com>,
Rony Efraim <ronye@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>
Subject: [PATCH net-next V1 14/18] net/mlx5: E-Switch, Introduce Vport administration functions
Date: Sun, 29 Nov 2015 17:37:22 +0200 [thread overview]
Message-ID: <1448811446-18598-15-git-send-email-ogerlitz@mellanox.com> (raw)
In-Reply-To: <1448811446-18598-1-git-send-email-ogerlitz@mellanox.com>
From: Saeed Mahameed <saeedm@mellanox.com>
Implement set VF mac/link state and query VF config
to be used later in nedev VF ndos or any other management API.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 61 +++++++++++++++++++++++
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h | 10 +++-
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index a208be7..590a06c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1022,3 +1022,64 @@ void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe)
queue_work(esw->work_queue, &vport->vport_change_handler);
spin_unlock(&vport->lock);
}
+
+/* Vport Administration */
+#define ESW_ALLOWED(esw) \
+ (esw && MLX5_CAP_GEN(esw->dev, vport_group_manager) && mlx5_core_is_pf(esw->dev))
+#define LEGAL_VPORT(esw, vport) (vport >= 0 && vport < esw->total_vports)
+
+int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
+ int vport, u8 mac[ETH_ALEN])
+{
+ int err = 0;
+
+ if (!ESW_ALLOWED(esw))
+ return -EPERM;
+ if (!LEGAL_VPORT(esw, vport))
+ return -EINVAL;
+
+ err = mlx5_modify_nic_vport_mac_address(esw->dev, vport, mac);
+ if (err) {
+ mlx5_core_warn(esw->dev,
+ "Failed to mlx5_modify_nic_vport_mac vport(%d) err=(%d)\n",
+ vport, err);
+ return err;
+ }
+
+ return err;
+}
+
+int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
+ int vport, int link_state)
+{
+ if (!ESW_ALLOWED(esw))
+ return -EPERM;
+ if (!LEGAL_VPORT(esw, vport))
+ return -EINVAL;
+
+ return mlx5_modify_vport_admin_state(esw->dev,
+ MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT,
+ vport, link_state);
+}
+
+int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
+ int vport, struct ifla_vf_info *ivi)
+{
+ if (!ESW_ALLOWED(esw))
+ return -EPERM;
+ if (!LEGAL_VPORT(esw, vport))
+ return -EINVAL;
+
+ memset(ivi, 0, sizeof(*ivi));
+ ivi->vf = vport - 1;
+
+ mlx5_query_nic_vport_mac_address(esw->dev, vport, ivi->mac);
+ ivi->linkstate = mlx5_query_vport_admin_state(esw->dev,
+ MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT,
+ vport);
+ ivi->vlan = 0;
+ ivi->qos = 0;
+ ivi->spoofchk = 0;
+
+ return 0;
+}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
index aec1ec0..c5827ad 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -33,6 +33,8 @@
#ifndef __MLX5_ESWITCH_H__
#define __MLX5_ESWITCH_H__
+#include <linux/if_ether.h>
+#include <linux/if_link.h>
#include <linux/mlx5/device.h>
#define MLX5_MAX_UC_PER_VPORT(dev) \
@@ -139,10 +141,16 @@ struct mlx5_eswitch {
/* E-Switch API */
int mlx5_eswitch_init(struct mlx5_core_dev *dev);
+
void mlx5_eswitch_cleanup(struct mlx5_eswitch *esw);
void mlx5_eswitch_vport_event(struct mlx5_eswitch *esw, struct mlx5_eqe *eqe);
int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs);
void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw);
-
+int mlx5_eswitch_set_vport_mac(struct mlx5_eswitch *esw,
+ int vport, u8 mac[ETH_ALEN]);
+int mlx5_eswitch_set_vport_state(struct mlx5_eswitch *esw,
+ int vport, int link_state);
+int mlx5_eswitch_get_vport_config(struct mlx5_eswitch *esw,
+ int vport, struct ifla_vf_info *ivi);
#endif /* __MLX5_ESWITCH_H__ */
--
2.3.7
next prev parent reply other threads:[~2015-11-29 15:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 15:37 [PATCH net-next V1 00/18] Introducing ConnectX-4 Ethernet SRIOV Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 01/18] net/mlx5_core: Modify enable/disable hca functions Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 02/18] net/mlx5_core: Add base sriov support Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 03/18] net/mlx5: Add HW capabilities and structs for SR-IOV E-Switch Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 04/18] net/mlx5: Update access functions to Query/Modify vport MAC address Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 05/18] net/mlx5: Introduce access functions to modify/query vport mac lists Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 06/18] net/mlx5: Introduce access functions to modify/query vport state Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 07/18] net/mlx5: Introduce access functions to modify/query vport promisc mode Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 08/18] net/mlx5: Introduce access functions to modify/query vport vlans Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 09/18] net/mlx5e: Write UC/MC list and promisc mode into vport context Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 10/18] net/mlx5e: Write vlan list " Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 11/18] net/mlx5: Introducing E-Switch and l2 table Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 12/18] net/mlx5: E-Switch, Introduce FDB hardware capabilities Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 13/18] net/mlx5: E-Switch, Add SR-IOV (FDB) support Or Gerlitz
2015-11-29 15:37 ` Or Gerlitz [this message]
2015-11-29 15:37 ` [PATCH net-next V1 15/18] net/mlx5: E-Switch, Introduce HCA cap and E-Switch vport context Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 16/18] net/mlx5: E-Switch, Introduce set vport vlan (VST mode) Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 17/18] net/mlx5: E-Switch, Introduce get vf statistics Or Gerlitz
2015-11-29 15:37 ` [PATCH net-next V1 18/18] net/mlx5e: Add support for SR-IOV ndos Or Gerlitz
2015-11-29 16:35 ` kbuild test robot
2015-11-29 16:35 ` [PATCH] net/mlx5e: fix semicolon.cocci warnings kbuild test robot
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=1448811446-18598-15-git-send-email-ogerlitz@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=davem@davemloft.net \
--cc=ddutile@redhat.com \
--cc=dledford@redhat.com \
--cc=hadarh@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ronye@mellanox.com \
--cc=saeedm@mellanox.com \
--cc=talal@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox