mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-14 02:59:19 -04:00
octeon_ep: add ndo ops for VFs in PF driver
These APIs are needed to support applications that use netlink to get VF information from a PF driver. Signed-off-by: Shinas Rasheed <srasheed@marvell.com> Link: https://patch.msgid.link/20241206064135.2331790-1-srasheed@marvell.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
e58b4771af
commit
8a241ef9b9
@@ -1137,6 +1137,43 @@ static int octep_set_features(struct net_device *dev, netdev_features_t features
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int octep_get_vf_config(struct net_device *dev, int vf,
|
||||||
|
struct ifla_vf_info *ivi)
|
||||||
|
{
|
||||||
|
struct octep_device *oct = netdev_priv(dev);
|
||||||
|
|
||||||
|
ivi->vf = vf;
|
||||||
|
ether_addr_copy(ivi->mac, oct->vf_info[vf].mac_addr);
|
||||||
|
ivi->spoofchk = true;
|
||||||
|
ivi->linkstate = IFLA_VF_LINK_STATE_ENABLE;
|
||||||
|
ivi->trusted = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int octep_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
|
||||||
|
{
|
||||||
|
struct octep_device *oct = netdev_priv(dev);
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!is_valid_ether_addr(mac)) {
|
||||||
|
dev_err(&oct->pdev->dev, "Invalid MAC Address %pM\n", mac);
|
||||||
|
return -EADDRNOTAVAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev_dbg(&oct->pdev->dev, "set vf-%d mac to %pM\n", vf, mac);
|
||||||
|
ether_addr_copy(oct->vf_info[vf].mac_addr, mac);
|
||||||
|
oct->vf_info[vf].flags |= OCTEON_PFVF_FLAG_MAC_SET_BY_PF;
|
||||||
|
|
||||||
|
err = octep_ctrl_net_set_mac_addr(oct, vf, mac, true);
|
||||||
|
if (err)
|
||||||
|
dev_err(&oct->pdev->dev,
|
||||||
|
"Set VF%d MAC address failed via host control Mbox\n",
|
||||||
|
vf);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct net_device_ops octep_netdev_ops = {
|
static const struct net_device_ops octep_netdev_ops = {
|
||||||
.ndo_open = octep_open,
|
.ndo_open = octep_open,
|
||||||
.ndo_stop = octep_stop,
|
.ndo_stop = octep_stop,
|
||||||
@@ -1146,6 +1183,8 @@ static const struct net_device_ops octep_netdev_ops = {
|
|||||||
.ndo_set_mac_address = octep_set_mac,
|
.ndo_set_mac_address = octep_set_mac,
|
||||||
.ndo_change_mtu = octep_change_mtu,
|
.ndo_change_mtu = octep_change_mtu,
|
||||||
.ndo_set_features = octep_set_features,
|
.ndo_set_features = octep_set_features,
|
||||||
|
.ndo_get_vf_config = octep_get_vf_config,
|
||||||
|
.ndo_set_vf_mac = octep_set_vf_mac
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ struct octep_iface_link_info {
|
|||||||
/* The Octeon VF device specific info data structure.*/
|
/* The Octeon VF device specific info data structure.*/
|
||||||
struct octep_pfvf_info {
|
struct octep_pfvf_info {
|
||||||
u8 mac_addr[ETH_ALEN];
|
u8 mac_addr[ETH_ALEN];
|
||||||
|
u32 flags;
|
||||||
u32 mbox_version;
|
u32 mbox_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -156,12 +156,23 @@ static void octep_pfvf_set_mac_addr(struct octep_device *oct, u32 vf_id,
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (oct->vf_info[vf_id].flags & OCTEON_PFVF_FLAG_MAC_SET_BY_PF) {
|
||||||
|
dev_err(&oct->pdev->dev,
|
||||||
|
"VF%d attempted to override administrative set MAC address\n",
|
||||||
|
vf_id);
|
||||||
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
err = octep_ctrl_net_set_mac_addr(oct, vf_id, cmd.s_set_mac.mac_addr, true);
|
err = octep_ctrl_net_set_mac_addr(oct, vf_id, cmd.s_set_mac.mac_addr, true);
|
||||||
if (err) {
|
if (err) {
|
||||||
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
|
||||||
dev_err(&oct->pdev->dev, "Set VF MAC address failed via host control Mbox\n");
|
dev_err(&oct->pdev->dev, "Set VF%d MAC address failed via host control Mbox\n",
|
||||||
|
vf_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ether_addr_copy(oct->vf_info[vf_id].mac_addr, cmd.s_set_mac.mac_addr);
|
||||||
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,10 +182,18 @@ static void octep_pfvf_get_mac_addr(struct octep_device *oct, u32 vf_id,
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (oct->vf_info[vf_id].flags & OCTEON_PFVF_FLAG_MAC_SET_BY_PF) {
|
||||||
|
dev_dbg(&oct->pdev->dev, "VF%d MAC address set by PF\n", vf_id);
|
||||||
|
ether_addr_copy(rsp->s_set_mac.mac_addr,
|
||||||
|
oct->vf_info[vf_id].mac_addr);
|
||||||
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
|
||||||
|
return;
|
||||||
|
}
|
||||||
err = octep_ctrl_net_get_mac_addr(oct, vf_id, rsp->s_set_mac.mac_addr);
|
err = octep_ctrl_net_get_mac_addr(oct, vf_id, rsp->s_set_mac.mac_addr);
|
||||||
if (err) {
|
if (err) {
|
||||||
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_NACK;
|
||||||
dev_err(&oct->pdev->dev, "Get VF MAC address failed via host control Mbox\n");
|
dev_err(&oct->pdev->dev, "Get VF%d MAC address failed via host control Mbox\n",
|
||||||
|
vf_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
|
rsp->s_set_mac.type = OCTEP_PFVF_MBOX_TYPE_RSP_ACK;
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
#ifndef _OCTEP_PFVF_MBOX_H_
|
#ifndef _OCTEP_PFVF_MBOX_H_
|
||||||
#define _OCTEP_PFVF_MBOX_H_
|
#define _OCTEP_PFVF_MBOX_H_
|
||||||
|
|
||||||
/* VF flags */
|
|
||||||
#define OCTEON_PFVF_FLAG_MAC_SET_BY_PF BIT_ULL(0) /* PF has set VF MAC address */
|
|
||||||
#define OCTEON_SDP_16K_HW_FRS 16380UL
|
#define OCTEON_SDP_16K_HW_FRS 16380UL
|
||||||
#define OCTEON_SDP_64K_HW_FRS 65531UL
|
#define OCTEON_SDP_64K_HW_FRS 65531UL
|
||||||
|
|
||||||
@@ -23,6 +21,10 @@ enum octep_pfvf_mbox_version {
|
|||||||
|
|
||||||
#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V2
|
#define OCTEP_PFVF_MBOX_VERSION_CURRENT OCTEP_PFVF_MBOX_VERSION_V2
|
||||||
|
|
||||||
|
/* VF flags */
|
||||||
|
/* PF has set VF MAC address */
|
||||||
|
#define OCTEON_PFVF_FLAG_MAC_SET_BY_PF BIT(0)
|
||||||
|
|
||||||
enum octep_pfvf_mbox_opcode {
|
enum octep_pfvf_mbox_opcode {
|
||||||
OCTEP_PFVF_MBOX_CMD_VERSION,
|
OCTEP_PFVF_MBOX_CMD_VERSION,
|
||||||
OCTEP_PFVF_MBOX_CMD_SET_MTU,
|
OCTEP_PFVF_MBOX_CMD_SET_MTU,
|
||||||
|
|||||||
Reference in New Issue
Block a user