Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /****************************************************************************
0003  * Driver for Solarflare network controllers and boards
0004  * Copyright 2014-2015 Solarflare Communications Inc.
0005  */
0006 #include <linux/module.h>
0007 #include "net_driver.h"
0008 #include "nic.h"
0009 #include "sriov.h"
0010 
0011 int efx_sriov_set_vf_mac(struct net_device *net_dev, int vf_i, u8 *mac)
0012 {
0013     struct efx_nic *efx = efx_netdev_priv(net_dev);
0014 
0015     if (efx->type->sriov_set_vf_mac)
0016         return efx->type->sriov_set_vf_mac(efx, vf_i, mac);
0017     else
0018         return -EOPNOTSUPP;
0019 }
0020 
0021 int efx_sriov_set_vf_vlan(struct net_device *net_dev, int vf_i, u16 vlan,
0022               u8 qos, __be16 vlan_proto)
0023 {
0024     struct efx_nic *efx = efx_netdev_priv(net_dev);
0025 
0026     if (efx->type->sriov_set_vf_vlan) {
0027         if ((vlan & ~VLAN_VID_MASK) ||
0028             (qos & ~(VLAN_PRIO_MASK >> VLAN_PRIO_SHIFT)))
0029             return -EINVAL;
0030 
0031         if (vlan_proto != htons(ETH_P_8021Q))
0032             return -EPROTONOSUPPORT;
0033 
0034         return efx->type->sriov_set_vf_vlan(efx, vf_i, vlan, qos);
0035     } else {
0036         return -EOPNOTSUPP;
0037     }
0038 }
0039 
0040 int efx_sriov_set_vf_spoofchk(struct net_device *net_dev, int vf_i,
0041                   bool spoofchk)
0042 {
0043     struct efx_nic *efx = efx_netdev_priv(net_dev);
0044 
0045     if (efx->type->sriov_set_vf_spoofchk)
0046         return efx->type->sriov_set_vf_spoofchk(efx, vf_i, spoofchk);
0047     else
0048         return -EOPNOTSUPP;
0049 }
0050 
0051 int efx_sriov_get_vf_config(struct net_device *net_dev, int vf_i,
0052                 struct ifla_vf_info *ivi)
0053 {
0054     struct efx_nic *efx = efx_netdev_priv(net_dev);
0055 
0056     if (efx->type->sriov_get_vf_config)
0057         return efx->type->sriov_get_vf_config(efx, vf_i, ivi);
0058     else
0059         return -EOPNOTSUPP;
0060 }
0061 
0062 int efx_sriov_set_vf_link_state(struct net_device *net_dev, int vf_i,
0063                 int link_state)
0064 {
0065     struct efx_nic *efx = efx_netdev_priv(net_dev);
0066 
0067     if (efx->type->sriov_set_vf_link_state)
0068         return efx->type->sriov_set_vf_link_state(efx, vf_i,
0069                               link_state);
0070     else
0071         return -EOPNOTSUPP;
0072 }