xref: /openbmc/linux/drivers/net/ethernet/sfc/siena/sriov.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1d48523cbSMartin Habets /* SPDX-License-Identifier: GPL-2.0-only */
2d48523cbSMartin Habets /****************************************************************************
3d48523cbSMartin Habets  * Driver for Solarflare network controllers and boards
4d48523cbSMartin Habets  * Copyright 2014-2015 Solarflare Communications Inc.
5d48523cbSMartin Habets  */
6d48523cbSMartin Habets 
7d48523cbSMartin Habets #ifndef EFX_SRIOV_H
8d48523cbSMartin Habets #define EFX_SRIOV_H
9d48523cbSMartin Habets 
10d48523cbSMartin Habets #include "net_driver.h"
11d48523cbSMartin Habets 
12*dfb1cfbdSMartin Habets #ifdef CONFIG_SFC_SIENA_SRIOV
13d48523cbSMartin Habets 
14782f7130SMartin Habets static inline
efx_sriov_set_vf_mac(struct net_device * net_dev,int vf_i,u8 * mac)15782f7130SMartin Habets int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
16782f7130SMartin Habets {
17782f7130SMartin Habets 	struct efx_nic *efx = netdev_priv(net_dev);
18782f7130SMartin Habets 
19782f7130SMartin Habets 	if (efx->type->sriov_set_vf_mac)
20782f7130SMartin Habets 		return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
21782f7130SMartin Habets 	else
22782f7130SMartin Habets 		return -EOPNOTSUPP;
23782f7130SMartin Habets }
24782f7130SMartin Habets 
25782f7130SMartin Habets static inline
efx_sriov_set_vf_vlan(struct net_device * net_dev,int vf_i,u16 vlan,u8 qos,__be16 vlan_proto)26d48523cbSMartin Habets int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
27782f7130SMartin Habets 			  u8 qos, __be16 vlan_proto)
28782f7130SMartin Habets {
29782f7130SMartin Habets 	struct efx_nic *efx = netdev_priv(net_dev);
30782f7130SMartin Habets 
31782f7130SMartin Habets 	if (efx->type->sriov_set_vf_vlan) {
32782f7130SMartin Habets 		if ((vlan & ~VLAN_VID_MASK) ||
33782f7130SMartin Habets 		    (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
34782f7130SMartin Habets 			return -EINVAL;
35782f7130SMartin Habets 
36782f7130SMartin Habets 		if (vlan_proto != htons(ETH_P_8021Q))
37782f7130SMartin Habets 			return -EPROTONOSUPPORT;
38782f7130SMartin Habets 
39782f7130SMartin Habets 		return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
40782f7130SMartin Habets 	} else {
41782f7130SMartin Habets 		return -EOPNOTSUPP;
42782f7130SMartin Habets 	}
43782f7130SMartin Habets }
44782f7130SMartin Habets 
45782f7130SMartin Habets static inline
efx_sriov_set_vf_spoofchk(struct net_device * net_dev,int vf_i,bool spoofchk)46d48523cbSMartin Habets int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
47782f7130SMartin Habets 			      bool spoofchk)
48782f7130SMartin Habets {
49782f7130SMartin Habets 	struct efx_nic *efx = netdev_priv(net_dev);
50782f7130SMartin Habets 
51782f7130SMartin Habets 	if (efx->type->sriov_set_vf_spoofchk)
52782f7130SMartin Habets 		return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
53782f7130SMartin Habets 	else
54782f7130SMartin Habets 		return -EOPNOTSUPP;
55782f7130SMartin Habets }
56782f7130SMartin Habets 
57782f7130SMartin Habets static inline
efx_sriov_get_vf_config(struct net_device * net_dev,int vf_i,struct ifla_vf_info * ivi)58d48523cbSMartin Habets int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
59782f7130SMartin Habets 			    struct ifla_vf_info *ivi)
60782f7130SMartin Habets {
61782f7130SMartin Habets 	struct efx_nic *efx = netdev_priv(net_dev);
62782f7130SMartin Habets 
63782f7130SMartin Habets 	if (efx->type->sriov_get_vf_config)
64782f7130SMartin Habets 		return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
65782f7130SMartin Habets 	else
66782f7130SMartin Habets 		return -EOPNOTSUPP;
67782f7130SMartin Habets }
68782f7130SMartin Habets 
69782f7130SMartin Habets static inline
efx_sriov_set_vf_link_state(struct net_device * net_dev,int vf_i,int link_state)70d48523cbSMartin Habets int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
71782f7130SMartin Habets 				int link_state)
72782f7130SMartin Habets {
73782f7130SMartin Habets 	struct efx_nic *efx = netdev_priv(net_dev);
74782f7130SMartin Habets 
75782f7130SMartin Habets 	if (efx->type->sriov_set_vf_link_state)
76782f7130SMartin Habets 		return efx->type->sriov_set_vf_link_state(efx, vf_i,
77782f7130SMartin Habets 							  link_state);
78782f7130SMartin Habets 	else
79782f7130SMartin Habets 		return -EOPNOTSUPP;
80782f7130SMartin Habets }
81*dfb1cfbdSMartin Habets #endif /* CONFIG_SFC_SIENA_SRIOV */
82d48523cbSMartin Habets 
83d48523cbSMartin Habets #endif /* EFX_SRIOV_H */
84