Skip to content

Commit 2cccb9e

Browse files
Rony Efraimdavem330
authored andcommitted
net/mlx4: Add support to get VF config
Support getting VF config. Signed-off-by: Rony Efraim <ronye@mellanox.com> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e6b6a23 commit 2cccb9e

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

drivers/net/ethernet/mellanox/mlx4/cmd.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,3 +2151,36 @@ int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting)
21512151
return 0;
21522152
}
21532153
EXPORT_SYMBOL_GPL(mlx4_set_vf_spoofchk);
2154+
2155+
int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_info *ivf)
2156+
{
2157+
struct mlx4_priv *priv = mlx4_priv(dev);
2158+
struct mlx4_vport_state *s_info;
2159+
int slave;
2160+
2161+
if (!mlx4_is_master(dev))
2162+
return -EPROTONOSUPPORT;
2163+
2164+
slave = mlx4_get_slave_indx(dev, vf);
2165+
if (slave < 0)
2166+
return -EINVAL;
2167+
2168+
s_info = &priv->mfunc.master.vf_admin[slave].vport[port];
2169+
ivf->vf = vf;
2170+
2171+
/* need to convert it to a func */
2172+
ivf->mac[0] = ((s_info->mac >> (5*8)) & 0xff);
2173+
ivf->mac[1] = ((s_info->mac >> (4*8)) & 0xff);
2174+
ivf->mac[2] = ((s_info->mac >> (3*8)) & 0xff);
2175+
ivf->mac[3] = ((s_info->mac >> (2*8)) & 0xff);
2176+
ivf->mac[4] = ((s_info->mac >> (1*8)) & 0xff);
2177+
ivf->mac[5] = ((s_info->mac) & 0xff);
2178+
2179+
ivf->vlan = s_info->default_vlan;
2180+
ivf->qos = s_info->default_qos;
2181+
ivf->tx_rate = s_info->tx_rate;
2182+
ivf->spoofchk = s_info->spoofchk;
2183+
2184+
return 0;
2185+
}
2186+
EXPORT_SYMBOL_GPL(mlx4_get_vf_config);

drivers/net/ethernet/mellanox/mlx4/en_netdev.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,13 @@ static int mlx4_en_set_vf_spoofchk(struct net_device *dev, int vf, bool setting)
20522052
return mlx4_set_vf_spoofchk(mdev->dev, en_priv->port, vf, setting);
20532053
}
20542054

2055+
static int mlx4_en_get_vf_config(struct net_device *dev, int vf, struct ifla_vf_info *ivf)
2056+
{
2057+
struct mlx4_en_priv *en_priv = netdev_priv(dev);
2058+
struct mlx4_en_dev *mdev = en_priv->mdev;
2059+
2060+
return mlx4_get_vf_config(mdev->dev, en_priv->port, vf, ivf);
2061+
}
20552062

20562063
static const struct net_device_ops mlx4_netdev_ops = {
20572064
.ndo_open = mlx4_en_open,
@@ -2093,6 +2100,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
20932100
.ndo_set_vf_mac = mlx4_en_set_vf_mac,
20942101
.ndo_set_vf_vlan = mlx4_en_set_vf_vlan,
20952102
.ndo_set_vf_spoofchk = mlx4_en_set_vf_spoofchk,
2103+
.ndo_get_vf_config = mlx4_en_get_vf_config,
20962104
#ifdef CONFIG_NET_POLL_CONTROLLER
20972105
.ndo_poll_controller = mlx4_en_netpoll,
20982106
#endif

include/linux/mlx4/cmd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#define MLX4_CMD_H
3535

3636
#include <linux/dma-mapping.h>
37+
#include <linux/if_link.h>
3738

3839
enum {
3940
/* initialization and general commands */
@@ -235,6 +236,7 @@ u32 mlx4_comm_get_version(void);
235236
int mlx4_set_vf_mac(struct mlx4_dev *dev, int port, int vf, u64 mac);
236237
int mlx4_set_vf_vlan(struct mlx4_dev *dev, int port, int vf, u16 vlan, u8 qos);
237238
int mlx4_set_vf_spoofchk(struct mlx4_dev *dev, int port, int vf, bool setting);
239+
int mlx4_get_vf_config(struct mlx4_dev *dev, int port, int vf, struct ifla_vf_info *ivf);
238240

239241

240242
#define MLX4_COMM_GET_IF_REV(cmd_chan_ver) (u8)((cmd_chan_ver) >> 8)

0 commit comments

Comments
 (0)