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 | |
7 | #ifndef EFX_SRIOV_H |
8 | #define EFX_SRIOV_H |
9 | |
10 | #include "net_driver.h" |
11 | |
12 | #ifdef CONFIG_SFC_SIENA_SRIOV |
13 | |
14 | static inline |
15 | int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac) |
16 | { |
17 | struct efx_nic *efx = netdev_priv(dev: net_dev); |
18 | |
19 | if (efx->type->sriov_set_vf_mac) |
20 | return efx->type->sriov_set_vf_mac(efx, vf_i, mac); |
21 | else |
22 | return -EOPNOTSUPP; |
23 | } |
24 | |
25 | static inline |
26 | int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan, |
27 | u8 qos, __be16 vlan_proto) |
28 | { |
29 | struct efx_nic *efx = netdev_priv(dev: net_dev); |
30 | |
31 | if (efx->type->sriov_set_vf_vlan) { |
32 | if ((vlan & ~VLAN_VID_MASK) || |
33 | (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT))) |
34 | return -EINVAL; |
35 | |
36 | if (vlan_proto != htons(ETH_P_8021Q)) |
37 | return -EPROTONOSUPPORT; |
38 | |
39 | return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos); |
40 | } else { |
41 | return -EOPNOTSUPP; |
42 | } |
43 | } |
44 | |
45 | static inline |
46 | int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i, |
47 | bool spoofchk) |
48 | { |
49 | struct efx_nic *efx = netdev_priv(dev: net_dev); |
50 | |
51 | if (efx->type->sriov_set_vf_spoofchk) |
52 | return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk); |
53 | else |
54 | return -EOPNOTSUPP; |
55 | } |
56 | |
57 | static inline |
58 | int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i, |
59 | struct ifla_vf_info *ivi) |
60 | { |
61 | struct efx_nic *efx = netdev_priv(dev: net_dev); |
62 | |
63 | if (efx->type->sriov_get_vf_config) |
64 | return efx->type->sriov_get_vf_config(efx, vf_i, ivi); |
65 | else |
66 | return -EOPNOTSUPP; |
67 | } |
68 | |
69 | static inline |
70 | int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i, |
71 | int link_state) |
72 | { |
73 | struct efx_nic *efx = netdev_priv(dev: net_dev); |
74 | |
75 | if (efx->type->sriov_set_vf_link_state) |
76 | return efx->type->sriov_set_vf_link_state(efx, vf_i, |
77 | link_state); |
78 | else |
79 | return -EOPNOTSUPP; |
80 | } |
81 | #endif /* CONFIG_SFC_SIENA_SRIOV */ |
82 | |
83 | #endif /* EFX_SRIOV_H */ |
84 | |