Linux Audio

Check our new training course

Loading...
v6.8
 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#include <linux/module.h>
 7#include "net_driver.h"
 8#include "nic.h"
 9#include "sriov.h"
10
11int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
12{
13	struct efx_nic *efx = efx_netdev_priv(net_dev);
14
15	if (efx->type->sriov_set_vf_mac)
16		return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
17	else
18		return -EOPNOTSUPP;
19}
20
21int 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	if (efx->type->sriov_set_vf_vlan) {
27		if ((vlan & ~VLAN_VID_MASK) ||
28		    (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
29			return -EINVAL;
30
31		if (vlan_proto != htons(ETH_P_8021Q))
32			return -EPROTONOSUPPORT;
33
34		return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
35	} else {
36		return -EOPNOTSUPP;
37	}
38}
39
40int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
41			      bool spoofchk)
42{
43	struct efx_nic *efx = efx_netdev_priv(net_dev);
44
45	if (efx->type->sriov_set_vf_spoofchk)
46		return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
47	else
48		return -EOPNOTSUPP;
49}
50
51int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
52			    struct ifla_vf_info *ivi)
53{
54	struct efx_nic *efx = efx_netdev_priv(net_dev);
55
56	if (efx->type->sriov_get_vf_config)
57		return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
58	else
59		return -EOPNOTSUPP;
60}
61
62int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
63				int link_state)
64{
65	struct efx_nic *efx = efx_netdev_priv(net_dev);
66
67	if (efx->type->sriov_set_vf_link_state)
68		return efx->type->sriov_set_vf_link_state(efx, vf_i,
69							  link_state);
70	else
71		return -EOPNOTSUPP;
72}
v4.17
 
 1/****************************************************************************
 2 * Driver for Solarflare network controllers and boards
 3 * Copyright 2014-2015 Solarflare Communications Inc.
 4 *
 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"
13
14int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
15{
16	struct efx_nic *efx = netdev_priv(net_dev);
17
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;
22}
23
24int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
25			  u8 qos, __be16 vlan_proto)
26{
27	struct efx_nic *efx = netdev_priv(net_dev);
28
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;
33
34		if (vlan_proto != htons(ETH_P_8021Q))
35			return -EPROTONOSUPPORT;
36
37		return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
38	} else {
39		return -EOPNOTSUPP;
40	}
41}
42
43int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
44			      bool spoofchk)
45{
46	struct efx_nic *efx = netdev_priv(net_dev);
47
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;
52}
53
54int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
55			    struct ifla_vf_info *ivi)
56{
57	struct efx_nic *efx = netdev_priv(net_dev);
58
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;
63}
64
65int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
66				int link_state)
67{
68	struct efx_nic *efx = netdev_priv(net_dev);
69
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;
75}