1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright 2011 Cisco Systems, Inc. All rights reserved.
5 #include <linux/etherdevice.h>
13 int enic_dev_fw_info(struct enic
*enic
, struct vnic_devcmd_fw_info
**fw_info
)
17 spin_lock_bh(&enic
->devcmd_lock
);
18 err
= vnic_dev_fw_info(enic
->vdev
, fw_info
);
19 spin_unlock_bh(&enic
->devcmd_lock
);
24 int enic_dev_stats_dump(struct enic
*enic
, struct vnic_stats
**vstats
)
28 spin_lock_bh(&enic
->devcmd_lock
);
29 err
= vnic_dev_stats_dump(enic
->vdev
, vstats
);
30 spin_unlock_bh(&enic
->devcmd_lock
);
35 int enic_dev_add_station_addr(struct enic
*enic
)
39 if (!is_valid_ether_addr(enic
->netdev
->dev_addr
))
40 return -EADDRNOTAVAIL
;
42 spin_lock_bh(&enic
->devcmd_lock
);
43 err
= vnic_dev_add_addr(enic
->vdev
, enic
->netdev
->dev_addr
);
44 spin_unlock_bh(&enic
->devcmd_lock
);
49 int enic_dev_del_station_addr(struct enic
*enic
)
53 if (!is_valid_ether_addr(enic
->netdev
->dev_addr
))
54 return -EADDRNOTAVAIL
;
56 spin_lock_bh(&enic
->devcmd_lock
);
57 err
= vnic_dev_del_addr(enic
->vdev
, enic
->netdev
->dev_addr
);
58 spin_unlock_bh(&enic
->devcmd_lock
);
63 int enic_dev_packet_filter(struct enic
*enic
, int directed
, int multicast
,
64 int broadcast
, int promisc
, int allmulti
)
68 spin_lock_bh(&enic
->devcmd_lock
);
69 err
= vnic_dev_packet_filter(enic
->vdev
, directed
,
70 multicast
, broadcast
, promisc
, allmulti
);
71 spin_unlock_bh(&enic
->devcmd_lock
);
76 int enic_dev_add_addr(struct enic
*enic
, const u8
*addr
)
80 spin_lock_bh(&enic
->devcmd_lock
);
81 err
= vnic_dev_add_addr(enic
->vdev
, addr
);
82 spin_unlock_bh(&enic
->devcmd_lock
);
87 int enic_dev_del_addr(struct enic
*enic
, const u8
*addr
)
91 spin_lock_bh(&enic
->devcmd_lock
);
92 err
= vnic_dev_del_addr(enic
->vdev
, addr
);
93 spin_unlock_bh(&enic
->devcmd_lock
);
98 int enic_dev_notify_unset(struct enic
*enic
)
102 spin_lock_bh(&enic
->devcmd_lock
);
103 err
= vnic_dev_notify_unset(enic
->vdev
);
104 spin_unlock_bh(&enic
->devcmd_lock
);
109 int enic_dev_hang_notify(struct enic
*enic
)
113 spin_lock_bh(&enic
->devcmd_lock
);
114 err
= vnic_dev_hang_notify(enic
->vdev
);
115 spin_unlock_bh(&enic
->devcmd_lock
);
120 int enic_dev_set_ig_vlan_rewrite_mode(struct enic
*enic
)
124 spin_lock_bh(&enic
->devcmd_lock
);
125 err
= vnic_dev_set_ig_vlan_rewrite_mode(enic
->vdev
,
126 IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN
);
127 spin_unlock_bh(&enic
->devcmd_lock
);
132 int enic_dev_enable(struct enic
*enic
)
136 spin_lock_bh(&enic
->devcmd_lock
);
137 err
= vnic_dev_enable_wait(enic
->vdev
);
138 spin_unlock_bh(&enic
->devcmd_lock
);
143 int enic_dev_disable(struct enic
*enic
)
147 spin_lock_bh(&enic
->devcmd_lock
);
148 err
= vnic_dev_disable(enic
->vdev
);
149 spin_unlock_bh(&enic
->devcmd_lock
);
154 int enic_dev_intr_coal_timer_info(struct enic
*enic
)
158 spin_lock_bh(&enic
->devcmd_lock
);
159 err
= vnic_dev_intr_coal_timer_info(enic
->vdev
);
160 spin_unlock_bh(&enic
->devcmd_lock
);
165 /* rtnl lock is held */
166 int enic_vlan_rx_add_vid(struct net_device
*netdev
, __be16 proto
, u16 vid
)
168 struct enic
*enic
= netdev_priv(netdev
);
171 spin_lock_bh(&enic
->devcmd_lock
);
172 err
= enic_add_vlan(enic
, vid
);
173 spin_unlock_bh(&enic
->devcmd_lock
);
178 /* rtnl lock is held */
179 int enic_vlan_rx_kill_vid(struct net_device
*netdev
, __be16 proto
, u16 vid
)
181 struct enic
*enic
= netdev_priv(netdev
);
184 spin_lock_bh(&enic
->devcmd_lock
);
185 err
= enic_del_vlan(enic
, vid
);
186 spin_unlock_bh(&enic
->devcmd_lock
);
191 int enic_dev_status_to_errno(int devcmd_status
)
193 switch (devcmd_status
) {
204 case ERR_ECMDUNKNOWN
:
205 case ERR_ENOTSUPPORTED
:
215 case ERR_EINPROGRESS
:
219 return (devcmd_status
< 0) ? devcmd_status
: -1;