xref: /openbmc/linux/drivers/net/ethernet/sfc/sriov.c (revision 8cb03f4e)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
27fa8d547SShradha Shah /****************************************************************************
37fa8d547SShradha Shah  * Driver for Solarflare network controllers and boards
47fa8d547SShradha Shah  * Copyright 2014-2015 Solarflare Communications Inc.
57fa8d547SShradha Shah  */
67fa8d547SShradha Shah #include <linux/module.h>
77fa8d547SShradha Shah #include "net_driver.h"
87fa8d547SShradha Shah #include "nic.h"
97fa8d547SShradha Shah #include "sriov.h"
107fa8d547SShradha Shah 
efx_sriov_set_vf_mac(struct net_device * net_dev,int vf_i,u8 * mac)117fa8d547SShradha Shah int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
127fa8d547SShradha Shah {
13*8cb03f4eSJonathan Cooper 	struct efx_nic *efx = efx_netdev_priv(net_dev);
147fa8d547SShradha Shah 
157fa8d547SShradha Shah 	if (efx->type->sriov_set_vf_mac)
167fa8d547SShradha Shah 		return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
177fa8d547SShradha Shah 	else
187fa8d547SShradha Shah 		return -EOPNOTSUPP;
197fa8d547SShradha Shah }
207fa8d547SShradha Shah 
efx_sriov_set_vf_vlan(struct net_device * net_dev,int vf_i,u16 vlan,u8 qos,__be16 vlan_proto)217fa8d547SShradha Shah int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
2279aab093SMoshe Shemesh 			  u8 qos, __be16 vlan_proto)
237fa8d547SShradha Shah {
24*8cb03f4eSJonathan Cooper 	struct efx_nic *efx = efx_netdev_priv(net_dev);
257fa8d547SShradha Shah 
267fa8d547SShradha Shah 	if (efx->type->sriov_set_vf_vlan) {
277fa8d547SShradha Shah 		if ((vlan & ~VLAN_VID_MASK) ||
287fa8d547SShradha Shah 		    (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
297fa8d547SShradha Shah 			return -EINVAL;
307fa8d547SShradha Shah 
3179aab093SMoshe Shemesh 		if (vlan_proto != htons(ETH_P_8021Q))
3279aab093SMoshe Shemesh 			return -EPROTONOSUPPORT;
3379aab093SMoshe Shemesh 
347fa8d547SShradha Shah 		return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
357fa8d547SShradha Shah 	} else {
367fa8d547SShradha Shah 		return -EOPNOTSUPP;
377fa8d547SShradha Shah 	}
387fa8d547SShradha Shah }
397fa8d547SShradha Shah 
efx_sriov_set_vf_spoofchk(struct net_device * net_dev,int vf_i,bool spoofchk)407fa8d547SShradha Shah int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
417fa8d547SShradha Shah 			      bool spoofchk)
427fa8d547SShradha Shah {
43*8cb03f4eSJonathan Cooper 	struct efx_nic *efx = efx_netdev_priv(net_dev);
447fa8d547SShradha Shah 
457fa8d547SShradha Shah 	if (efx->type->sriov_set_vf_spoofchk)
467fa8d547SShradha Shah 		return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
477fa8d547SShradha Shah 	else
487fa8d547SShradha Shah 		return -EOPNOTSUPP;
497fa8d547SShradha Shah }
507fa8d547SShradha Shah 
efx_sriov_get_vf_config(struct net_device * net_dev,int vf_i,struct ifla_vf_info * ivi)517fa8d547SShradha Shah int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
527fa8d547SShradha Shah 			    struct ifla_vf_info *ivi)
537fa8d547SShradha Shah {
54*8cb03f4eSJonathan Cooper 	struct efx_nic *efx = efx_netdev_priv(net_dev);
557fa8d547SShradha Shah 
567fa8d547SShradha Shah 	if (efx->type->sriov_get_vf_config)
577fa8d547SShradha Shah 		return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
587fa8d547SShradha Shah 	else
597fa8d547SShradha Shah 		return -EOPNOTSUPP;
607fa8d547SShradha Shah }
614392dc69SEdward Cree 
efx_sriov_set_vf_link_state(struct net_device * net_dev,int vf_i,int link_state)624392dc69SEdward Cree int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
634392dc69SEdward Cree 				int link_state)
644392dc69SEdward Cree {
65*8cb03f4eSJonathan Cooper 	struct efx_nic *efx = efx_netdev_priv(net_dev);
664392dc69SEdward Cree 
674392dc69SEdward Cree 	if (efx->type->sriov_set_vf_link_state)
684392dc69SEdward Cree 		return efx->type->sriov_set_vf_link_state(efx, vf_i,
694392dc69SEdward Cree 							  link_state);
704392dc69SEdward Cree 	else
714392dc69SEdward Cree 		return -EOPNOTSUPP;
724392dc69SEdward Cree }
73