Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / net / ethernet / sfc / sriov.c
blobfc9f0189f285b8a532d1d525c6fa8c150665b772
1 // SPDX-License-Identifier: GPL-2.0-only
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2014-2015 Solarflare Communications Inc.
5 */
6 #include <linux/module.h>
7 #include "net_driver.h"
8 #include "nic.h"
9 #include "sriov.h"
11 int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
13 struct efx_nic *efx = efx_netdev_priv(net_dev);
15 if (efx->type->sriov_set_vf_mac)
16 return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
17 else
18 return -EOPNOTSUPP;
21 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
22 u8 qos, __be16 vlan_proto)
24 struct efx_nic *efx = efx_netdev_priv(net_dev);
26 if (efx->type->sriov_set_vf_vlan) {
27 if ((vlan & ~VLAN_VID_MASK) ||
28 (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
29 return -EINVAL;
31 if (vlan_proto != htons(ETH_P_8021Q))
32 return -EPROTONOSUPPORT;
34 return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
35 } else {
36 return -EOPNOTSUPP;
40 int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
41 bool spoofchk)
43 struct efx_nic *efx = efx_netdev_priv(net_dev);
45 if (efx->type->sriov_set_vf_spoofchk)
46 return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
47 else
48 return -EOPNOTSUPP;
51 int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
52 struct ifla_vf_info *ivi)
54 struct efx_nic *efx = efx_netdev_priv(net_dev);
56 if (efx->type->sriov_get_vf_config)
57 return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
58 else
59 return -EOPNOTSUPP;
62 int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
63 int link_state)
65 struct efx_nic *efx = efx_netdev_priv(net_dev);
67 if (efx->type->sriov_set_vf_link_state)
68 return efx->type->sriov_set_vf_link_state(efx, vf_i,
69 link_state);
70 else
71 return -EOPNOTSUPP;