Linux 4.16.11
[linux/fpc-iii.git] / drivers / net / ethernet / sfc / sriov.c
blob0b766fdbcddbbdb18d77d40d51ee3660d6454a77
1 /****************************************************************************
2 * Driver for Solarflare network controllers and boards
3 * Copyright 2014-2015 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9 #include <linux/module.h>
10 #include "net_driver.h"
11 #include "nic.h"
12 #include "sriov.h"
14 int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
16 struct efx_nic *efx = netdev_priv(net_dev);
18 if (efx->type->sriov_set_vf_mac)
19 return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
20 else
21 return -EOPNOTSUPP;
24 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
25 u8 qos, __be16 vlan_proto)
27 struct efx_nic *efx = netdev_priv(net_dev);
29 if (efx->type->sriov_set_vf_vlan) {
30 if ((vlan & ~VLAN_VID_MASK) ||
31 (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
32 return -EINVAL;
34 if (vlan_proto != htons(ETH_P_8021Q))
35 return -EPROTONOSUPPORT;
37 return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
38 } else {
39 return -EOPNOTSUPP;
43 int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
44 bool spoofchk)
46 struct efx_nic *efx = netdev_priv(net_dev);
48 if (efx->type->sriov_set_vf_spoofchk)
49 return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
50 else
51 return -EOPNOTSUPP;
54 int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
55 struct ifla_vf_info *ivi)
57 struct efx_nic *efx = netdev_priv(net_dev);
59 if (efx->type->sriov_get_vf_config)
60 return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
61 else
62 return -EOPNOTSUPP;
65 int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
66 int link_state)
68 struct efx_nic *efx = netdev_priv(net_dev);
70 if (efx->type->sriov_set_vf_link_state)
71 return efx->type->sriov_set_vf_link_state(efx, vf_i,
72 link_state);
73 else
74 return -EOPNOTSUPP;