2
* Copyright 2011 Cisco Systems, Inc. All rights reserved.
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.
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
19
#include <linux/pci.h>
20
#include <linux/etherdevice.h>
28
int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info)
32
spin_lock(&enic->devcmd_lock);
33
err = vnic_dev_fw_info(enic->vdev, fw_info);
34
spin_unlock(&enic->devcmd_lock);
39
int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats)
43
spin_lock(&enic->devcmd_lock);
44
err = vnic_dev_stats_dump(enic->vdev, vstats);
45
spin_unlock(&enic->devcmd_lock);
50
int enic_dev_add_station_addr(struct enic *enic)
54
if (!is_valid_ether_addr(enic->netdev->dev_addr))
55
return -EADDRNOTAVAIL;
57
spin_lock(&enic->devcmd_lock);
58
err = vnic_dev_add_addr(enic->vdev, enic->netdev->dev_addr);
59
spin_unlock(&enic->devcmd_lock);
64
int enic_dev_del_station_addr(struct enic *enic)
68
if (!is_valid_ether_addr(enic->netdev->dev_addr))
69
return -EADDRNOTAVAIL;
71
spin_lock(&enic->devcmd_lock);
72
err = vnic_dev_del_addr(enic->vdev, enic->netdev->dev_addr);
73
spin_unlock(&enic->devcmd_lock);
78
int enic_dev_packet_filter(struct enic *enic, int directed, int multicast,
79
int broadcast, int promisc, int allmulti)
83
spin_lock(&enic->devcmd_lock);
84
err = vnic_dev_packet_filter(enic->vdev, directed,
85
multicast, broadcast, promisc, allmulti);
86
spin_unlock(&enic->devcmd_lock);
91
int enic_dev_add_addr(struct enic *enic, u8 *addr)
95
spin_lock(&enic->devcmd_lock);
96
err = vnic_dev_add_addr(enic->vdev, addr);
97
spin_unlock(&enic->devcmd_lock);
102
int enic_dev_del_addr(struct enic *enic, u8 *addr)
106
spin_lock(&enic->devcmd_lock);
107
err = vnic_dev_del_addr(enic->vdev, addr);
108
spin_unlock(&enic->devcmd_lock);
113
int enic_dev_notify_unset(struct enic *enic)
117
spin_lock(&enic->devcmd_lock);
118
err = vnic_dev_notify_unset(enic->vdev);
119
spin_unlock(&enic->devcmd_lock);
124
int enic_dev_hang_notify(struct enic *enic)
128
spin_lock(&enic->devcmd_lock);
129
err = vnic_dev_hang_notify(enic->vdev);
130
spin_unlock(&enic->devcmd_lock);
135
int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic)
139
spin_lock(&enic->devcmd_lock);
140
err = vnic_dev_set_ig_vlan_rewrite_mode(enic->vdev,
141
IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN);
142
spin_unlock(&enic->devcmd_lock);
147
int enic_dev_enable(struct enic *enic)
151
spin_lock(&enic->devcmd_lock);
152
err = vnic_dev_enable_wait(enic->vdev);
153
spin_unlock(&enic->devcmd_lock);
158
int enic_dev_disable(struct enic *enic)
162
spin_lock(&enic->devcmd_lock);
163
err = vnic_dev_disable(enic->vdev);
164
spin_unlock(&enic->devcmd_lock);
169
int enic_vnic_dev_deinit(struct enic *enic)
173
spin_lock(&enic->devcmd_lock);
174
err = vnic_dev_deinit(enic->vdev);
175
spin_unlock(&enic->devcmd_lock);
180
int enic_dev_init_prov2(struct enic *enic, struct vic_provinfo *vp)
184
spin_lock(&enic->devcmd_lock);
185
err = vnic_dev_init_prov2(enic->vdev,
186
(u8 *)vp, vic_provinfo_size(vp));
187
spin_unlock(&enic->devcmd_lock);
192
int enic_dev_deinit_done(struct enic *enic, int *status)
196
spin_lock(&enic->devcmd_lock);
197
err = vnic_dev_deinit_done(enic->vdev, status);
198
spin_unlock(&enic->devcmd_lock);
203
/* rtnl lock is held */
204
void enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
206
struct enic *enic = netdev_priv(netdev);
208
spin_lock(&enic->devcmd_lock);
209
enic_add_vlan(enic, vid);
210
spin_unlock(&enic->devcmd_lock);
213
/* rtnl lock is held */
214
void enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
216
struct enic *enic = netdev_priv(netdev);
218
spin_lock(&enic->devcmd_lock);
219
enic_del_vlan(enic, vid);
220
spin_unlock(&enic->devcmd_lock);
223
int enic_dev_enable2(struct enic *enic, int active)
227
spin_lock(&enic->devcmd_lock);
228
err = vnic_dev_enable2(enic->vdev, active);
229
spin_unlock(&enic->devcmd_lock);
234
int enic_dev_enable2_done(struct enic *enic, int *status)
238
spin_lock(&enic->devcmd_lock);
239
err = vnic_dev_enable2_done(enic->vdev, status);
240
spin_unlock(&enic->devcmd_lock);
245
int enic_dev_status_to_errno(int devcmd_status)
247
switch (devcmd_status) {
258
case ERR_ECMDUNKNOWN:
259
case ERR_ENOTSUPPORTED:
269
case ERR_EINPROGRESS:
273
return (devcmd_status < 0) ? devcmd_status : -1;