Skip to content

Commit 0b03856

Browse files
Neel Pateldavem330
authored andcommitted
drivers/net: enic: Add an interface for USNIC to interact with firmware
This patch adds an interface for USNIC to proxy firmware commands through ENIC. Signed-off-by: Neel Patel <[email protected]> Signed-off-by: Nishank Trivedi <[email protected]> Signed-off-by: Christian Benvenuti <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 92e2b46 commit 0b03856

File tree

5 files changed

+83
-1
lines changed

5 files changed

+83
-1
lines changed

drivers/net/ethernet/cisco/enic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ obj-$(CONFIG_ENIC) := enic.o
22

33
enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \
44
enic_res.o enic_dev.o enic_pp.o vnic_dev.o vnic_rq.o vnic_vic.o \
5-
enic_ethtool.o
5+
enic_ethtool.o enic_api.o
66

drivers/net/ethernet/cisco/enic/enic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ struct enic {
9696
#ifdef CONFIG_PCI_IOV
9797
u16 num_vfs;
9898
#endif
99+
spinlock_t enic_api_lock;
99100
struct enic_port_profile *pp;
100101

101102
/* work queue cache line section */
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* Copyright 2013 Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#include <linux/netdevice.h>
20+
#include <linux/spinlock.h>
21+
22+
#include "vnic_dev.h"
23+
#include "vnic_devcmd.h"
24+
25+
#include "enic_res.h"
26+
#include "enic.h"
27+
#include "enic_api.h"
28+
29+
int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
30+
enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait)
31+
{
32+
int err;
33+
struct enic *enic = netdev_priv(netdev);
34+
struct vnic_dev *vdev = enic->vdev;
35+
36+
spin_lock(&enic->enic_api_lock);
37+
spin_lock(&enic->devcmd_lock);
38+
39+
vnic_dev_cmd_proxy_by_index_start(vdev, vf);
40+
err = vnic_dev_cmd(vdev, cmd, a0, a1, wait);
41+
vnic_dev_cmd_proxy_end(vdev);
42+
43+
spin_unlock(&enic->devcmd_lock);
44+
spin_unlock(&enic->enic_api_lock);
45+
46+
return err;
47+
}
48+
EXPORT_SYMBOL(enic_api_devcmd_proxy_by_index);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2013 Cisco Systems, Inc. All rights reserved.
3+
*
4+
* This program is free software; you may redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; version 2 of the License.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15+
* SOFTWARE.
16+
*
17+
*/
18+
19+
#ifndef __ENIC_API_H__
20+
#define __ENIC_API_H__
21+
22+
#include <linux/netdevice.h>
23+
24+
#include "vnic_dev.h"
25+
#include "vnic_devcmd.h"
26+
27+
int enic_api_devcmd_proxy_by_index(struct net_device *netdev, int vf,
28+
enum vnic_devcmd_cmd cmd, u64 *a0, u64 *a1, int wait);
29+
30+
#endif

drivers/net/ethernet/cisco/enic/enic_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,7 @@ static void enic_reset(struct work_struct *work)
17331733

17341734
rtnl_lock();
17351735

1736+
spin_lock(&enic->enic_api_lock);
17361737
enic_dev_hang_notify(enic);
17371738
enic_stop(enic->netdev);
17381739
enic_dev_hang_reset(enic);
@@ -1741,6 +1742,7 @@ static void enic_reset(struct work_struct *work)
17411742
enic_set_rss_nic_cfg(enic);
17421743
enic_dev_set_ig_vlan_rewrite_mode(enic);
17431744
enic_open(enic->netdev);
1745+
spin_unlock(&enic->enic_api_lock);
17441746

17451747
rtnl_unlock();
17461748
}
@@ -2153,6 +2155,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
21532155
*/
21542156

21552157
spin_lock_init(&enic->devcmd_lock);
2158+
spin_lock_init(&enic->enic_api_lock);
21562159

21572160
/*
21582161
* Set ingress vlan rewrite mode before vnic initialization

0 commit comments

Comments
 (0)