Page MenuHomeFreeBSD

D58740.diff
No OneTemporary

D58740.diff

diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
--- a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c
@@ -1221,6 +1221,7 @@
{
u16 vlan;
u8 qos;
+ int err;
if (!ESW_ALLOWED(esw))
return -EPERM;
@@ -1230,11 +1231,15 @@
memset(ivi, 0, sizeof(*ivi));
ivi->vf = vport - 1;
- mlx5_query_nic_vport_mac_address(esw->dev, vport, ivi->mac);
+ err = mlx5_query_nic_vport_mac_address(esw->dev, vport, ivi->mac);
+ if (err != 0)
+ return err;
ivi->linkstate = mlx5_query_vport_admin_state(esw->dev,
MLX5_QUERY_VPORT_STATE_IN_OP_MOD_ESW_VPORT,
vport);
- query_esw_vport_cvlan(esw->dev, vport, &vlan, &qos);
+ err = query_esw_vport_cvlan(esw->dev, vport, &vlan, &qos);
+ if (err != 0)
+ return err;
ivi->vlan = vlan;
ivi->qos = qos;
ivi->spoofchk = 0;
@@ -1273,4 +1278,3 @@
mutex_unlock(&evport->state_lock);
return err;
}
-
diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
--- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
+++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
@@ -37,14 +37,19 @@
#include <machine/atomic.h>
#include <net/debugnet.h>
+#include <net/if_vf_status.h>
#include <netinet/tcp_ratelimit.h>
#include <netipsec/keydb.h>
#include <netipsec/ipsec_offload.h>
+#include <dev/mlx5/mlx5_core/eswitch.h>
+
static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs);
static if_snd_tag_query_t mlx5e_ul_snd_tag_query;
static if_snd_tag_free_t mlx5e_ul_snd_tag_free;
+static int mlx5e_vf_status(if_t, struct if_vf_status **);
+
struct mlx5e_channel_param {
struct mlx5e_rq_param rq;
struct mlx5e_sq_param sq;
@@ -3521,6 +3526,101 @@
return (false);
}
+static int
+mlx5e_vf_status(if_t ifp, struct if_vf_status **statusp)
+{
+ struct mlx5e_vf_status {
+ u8 mac[ETH_ALEN];
+ u16 vlan;
+ u32 vf;
+ u32 linkstate;
+ } *snapshot;
+ struct mlx5_esw_vport_info info;
+ struct mlx5_eswitch *esw;
+ struct mlx5_vport *vport;
+ struct if_vf_info *vf;
+ struct if_vf_status *status;
+ struct mlx5e_priv *priv;
+ int error, i, num_vfs;
+
+ priv = if_getsoftc(ifp);
+ esw = priv->mdev->priv.eswitch;
+ if (esw == NULL || esw->total_vports <= 1)
+ return (ENXIO);
+ snapshot = mallocarray(esw->total_vports - 1, sizeof(*snapshot),
+ M_DEVBUF, M_WAITOK | M_ZERO);
+ num_vfs = 0;
+ for (i = 1; i < esw->total_vports; i++) {
+ vport = &esw->vports[i];
+ mutex_lock(&vport->state_lock);
+ if (!vport->enabled) {
+ mutex_unlock(&vport->state_lock);
+ continue;
+ }
+ /*
+ * The eswitch does not cache all effective vport policy. Query
+ * firmware while the vport is stable and return errors rather than
+ * publishing a partial snapshot.
+ */
+ error = mlx5_eswitch_get_vport_config(esw, i, &info);
+ mutex_unlock(&vport->state_lock);
+ if (error != 0) {
+ free(snapshot, M_DEVBUF);
+ return (-error);
+ }
+ snapshot[num_vfs].vf = info.vf;
+ snapshot[num_vfs].vlan = info.vlan;
+ snapshot[num_vfs].linkstate = info.linkstate;
+ memcpy(snapshot[num_vfs].mac, info.mac, ETH_ALEN);
+ num_vfs++;
+ }
+ if (num_vfs == 0) {
+ free(snapshot, M_DEVBUF);
+ return (ENXIO);
+ }
+
+ status = if_vf_status_alloc(num_vfs);
+ if (status == NULL) {
+ free(snapshot, M_DEVBUF);
+ return (ENOMEM);
+ }
+ for (i = 0; i < num_vfs; i++) {
+ vf = &status->vfs[i];
+ vf->fields = IFVF_F_CONFIGURED | IFVF_F_VLAN_MODE;
+ vf->index = snapshot[i].vf;
+ vf->configured = true;
+ if (!ETHER_IS_ZERO(snapshot[i].mac)) {
+ memcpy(vf->mac, snapshot[i].mac, sizeof(vf->mac));
+ vf->fields |= IFVF_F_MAC;
+ }
+ if (snapshot[i].vlan == 0)
+ vf->vlan_mode = IFVF_VLAN_TRUNK;
+ else {
+ vf->vlan_mode = IFVF_VLAN_ACCESS;
+ vf->vlan = snapshot[i].vlan;
+ vf->vlan_count = 1;
+ vf->fields |= IFVF_F_VLAN | IFVF_F_VLAN_COUNT;
+ }
+ switch (snapshot[i].linkstate) {
+ case MLX5_ESW_VPORT_ADMIN_STATE_DOWN:
+ vf->link_state_policy = IFVF_LINK_DOWN;
+ break;
+ case MLX5_ESW_VPORT_ADMIN_STATE_UP:
+ vf->link_state_policy = IFVF_LINK_UP;
+ break;
+ case MLX5_ESW_VPORT_ADMIN_STATE_AUTO:
+ vf->link_state_policy = IFVF_LINK_AUTO;
+ break;
+ default:
+ continue;
+ }
+ vf->fields |= IFVF_F_LINK_STATE_POLICY;
+ }
+ free(snapshot, M_DEVBUF);
+ *statusp = status;
+ return (0);
+}
+
static int
mlx5e_ioctl(if_t ifp, u_long command, caddr_t data)
{
@@ -4648,6 +4748,7 @@
if_setinitfn(ifp, mlx5e_open);
if_setflags(ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST);
if_setioctlfn(ifp, mlx5e_ioctl);
+ if_setvfstatusfn(ifp, mlx5e_vf_status);
if_settransmitfn(ifp, mlx5e_xmit);
if_setqflushfn(ifp, if_qflush);
if_setgetcounterfn(ifp, mlx5e_get_counter);

File Metadata

Mime Type
text/plain
Expires
Tue, Aug 18, 5:48 AM (39 m, 31 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36877935
Default Alt Text
D58740.diff (4 KB)

Event Timeline