Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright 2013 Cisco Systems, Inc.  All rights reserved.
0003 
0004 #include <linux/netdevice.h>
0005 #include <linux/spinlock.h>
0006 
0007 #include "vnic_dev.h"
0008 #include "vnic_devcmd.h"
0009 
0010 #include "enic_res.h"
0011 #include "enic.h"
0012 #include "enic_api.h"
0013 
0014 int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
0015     enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait)
0016 {
0017     int err;
0018     struct enic *enic = netdev_priv(netdev);
0019     struct vnic_dev *vdev = enic->vdev;
0020 
0021     spin_lock(&enic->enic_api_lock);
0022     while (enic->enic_api_busy) {
0023         spin_unlock(&enic->enic_api_lock);
0024         cpu_relax();
0025         spin_lock(&enic->enic_api_lock);
0026     }
0027 
0028     spin_lock_bh(&enic->devcmd_lock);
0029 
0030     vnic_dev_cmd_proxy_by_index_start(vdev, vf);
0031     err = vnic_dev_cmd(vdev, cmd, a0, a1, wait);
0032     vnic_dev_cmd_proxy_end(vdev);
0033 
0034     spin_unlock_bh(&enic->devcmd_lock);
0035     spin_unlock(&enic->enic_api_lock);
0036 
0037     return err;
0038 }
0039 EXPORT_SYMBOL(enic_api_devcmd_proxy_by_index);