sriov.c 1.8 KB
Newer Older
1
// SPDX-License-Identifier: GPL-2.0-only
2 3 4 5 6 7 8 9 10 11 12
/****************************************************************************
 * Driver for Solarflare network controllers and boards
 * Copyright 2014-2015 Solarflare Communications Inc.
 */
#include <linux/module.h>
#include "net_driver.h"
#include "nic.h"
#include "sriov.h"

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);
14 15 16 17 18 19 20 21

	if (efx->type->sriov_set_vf_mac)
		return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
	else
		return -EOPNOTSUPP;
}

int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
22
			  u8 qos, __be16 vlan_proto)
23
{
24
	struct efx_nic *efx = efx_netdev_priv(net_dev);
25 26 27 28 29 30

	if (efx->type->sriov_set_vf_vlan) {
		if ((vlan & ~VLAN_VID_MASK) ||
		    (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
			return -EINVAL;

31 32 33
		if (vlan_proto != htons(ETH_P_8021Q))
			return -EPROTONOSUPPORT;

34 35 36 37 38 39 40 41 42
		return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
	} else {
		return -EOPNOTSUPP;
	}
}

int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
			      bool spoofchk)
{
43
	struct efx_nic *efx = efx_netdev_priv(net_dev);
44 45 46 47 48 49 50 51 52 53

	if (efx->type->sriov_set_vf_spoofchk)
		return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
	else
		return -EOPNOTSUPP;
}

int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
			    struct ifla_vf_info *ivi)
{
54
	struct efx_nic *efx = efx_netdev_priv(net_dev);
55 56 57 58 59 60

	if (efx->type->sriov_get_vf_config)
		return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
	else
		return -EOPNOTSUPP;
}
61 62 63 64

int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
				int link_state)
{
65
	struct efx_nic *efx = efx_netdev_priv(net_dev);
66 67 68 69 70 71 72

	if (efx->type->sriov_set_vf_link_state)
		return efx->type->sriov_set_vf_link_state(efx, vf_i,
							  link_state);
	else
		return -EOPNOTSUPP;
}