Skip to content

Commit

Permalink
net: make vlan ndo_vlan_rx_[add/kill]_vid return error value
Browse files Browse the repository at this point in the history
Let caller know the result of adding/removing vlan id to/from vlan
filter.

In some drivers I make those functions to just return 0. But in those
where there is able to see if hw setup went correctly, return value is
set appropriately.

Signed-off-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Pirko authored and davem330 committed Dec 9, 2011
1 parent 7da82c0 commit 8e58613
Show file tree
Hide file tree
Showing 28 changed files with 210 additions and 107 deletions.
10 changes: 8 additions & 2 deletions drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
* @bond_dev: bonding net device that got called
* @vid: vlan id being added
*/
static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
static int bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
{
struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
Expand All @@ -448,15 +448,18 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
if (res) {
pr_err("%s: Error: Failed to add vlan id %d\n",
bond_dev->name, vid);
return res;
}

return 0;
}

/**
* bond_vlan_rx_kill_vid - Propagates deleting an id to slaves
* @bond_dev: bonding net device that got called
* @vid: vlan id being removed
*/
static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
static int bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
{
struct bonding *bond = netdev_priv(bond_dev);
struct slave *slave;
Expand All @@ -476,7 +479,10 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
if (res) {
pr_err("%s: Error: Failed to remove vlan id %d\n",
bond_dev->name, vid);
return res;
}

return 0;
}

static void bond_add_vlans_on_slave(struct bonding *bond, struct net_device *slave_dev)
Expand Down
8 changes: 6 additions & 2 deletions drivers/net/ethernet/adaptec/starfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ static const struct ethtool_ops ethtool_ops;


#ifdef VLAN_SUPPORT
static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
static int netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
{
struct netdev_private *np = netdev_priv(dev);

Expand All @@ -617,9 +617,11 @@ static void netdev_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
set_bit(vid, np->active_vlans);
set_rx_mode(dev);
spin_unlock(&np->lock);

return 0;
}

static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
static int netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
{
struct netdev_private *np = netdev_priv(dev);

Expand All @@ -629,6 +631,8 @@ static void netdev_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
clear_bit(vid, np->active_vlans);
set_rx_mode(dev);
spin_unlock(&np->lock);

return 0;
}
#endif /* VLAN_SUPPORT */

Expand Down
12 changes: 8 additions & 4 deletions drivers/net/ethernet/brocade/bna/bnad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2968,15 +2968,15 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
return err;
}

static void
static int
bnad_vlan_rx_add_vid(struct net_device *netdev,
unsigned short vid)
{
struct bnad *bnad = netdev_priv(netdev);
unsigned long flags;

if (!bnad->rx_info[0].rx)
return;
return 0;

mutex_lock(&bnad->conf_mutex);

Expand All @@ -2986,17 +2986,19 @@ bnad_vlan_rx_add_vid(struct net_device *netdev,
spin_unlock_irqrestore(&bnad->bna_lock, flags);

mutex_unlock(&bnad->conf_mutex);

return 0;
}

static void
static int
bnad_vlan_rx_kill_vid(struct net_device *netdev,
unsigned short vid)
{
struct bnad *bnad = netdev_priv(netdev);
unsigned long flags;

if (!bnad->rx_info[0].rx)
return;
return 0;

mutex_lock(&bnad->conf_mutex);

Expand All @@ -3006,6 +3008,8 @@ bnad_vlan_rx_kill_vid(struct net_device *netdev,
spin_unlock_irqrestore(&bnad->bna_lock, flags);

mutex_unlock(&bnad->conf_mutex);

return 0;
}

#ifdef CONFIG_NET_POLL_CONTROLLER
Expand Down
14 changes: 10 additions & 4 deletions drivers/net/ethernet/cisco/enic/enic_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,23 +212,29 @@ int enic_dev_deinit_done(struct enic *enic, int *status)
}

/* rtnl lock is held */
void enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
int enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
{
struct enic *enic = netdev_priv(netdev);
int err;

spin_lock(&enic->devcmd_lock);
enic_add_vlan(enic, vid);
err = enic_add_vlan(enic, vid);
spin_unlock(&enic->devcmd_lock);

return err;
}

/* rtnl lock is held */
void enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
int enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
{
struct enic *enic = netdev_priv(netdev);
int err;

spin_lock(&enic->devcmd_lock);
enic_del_vlan(enic, vid);
err = enic_del_vlan(enic, vid);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_enable2(struct enic *enic, int active)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/cisco/enic/enic_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ int enic_dev_packet_filter(struct enic *enic, int directed, int multicast,
int broadcast, int promisc, int allmulti);
int enic_dev_add_addr(struct enic *enic, u8 *addr);
int enic_dev_del_addr(struct enic *enic, u8 *addr);
void enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
void enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
int enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
int enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
int enic_dev_notify_unset(struct enic *enic);
int enic_dev_hang_notify(struct enic *enic);
int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic);
Expand Down
12 changes: 8 additions & 4 deletions drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,31 +780,35 @@ static int be_vid_config(struct be_adapter *adapter, bool vf, u32 vf_num)
return status;
}

static void be_vlan_add_vid(struct net_device *netdev, u16 vid)
static int be_vlan_add_vid(struct net_device *netdev, u16 vid)
{
struct be_adapter *adapter = netdev_priv(netdev);

adapter->vlans_added++;
if (!be_physfn(adapter))
return;
return 0;

adapter->vlan_tag[vid] = 1;
if (adapter->vlans_added <= (adapter->max_vlans + 1))
be_vid_config(adapter, false, 0);

return 0;
}

static void be_vlan_rem_vid(struct net_device *netdev, u16 vid)
static int be_vlan_rem_vid(struct net_device *netdev, u16 vid)
{
struct be_adapter *adapter = netdev_priv(netdev);

adapter->vlans_added--;

if (!be_physfn(adapter))
return;
return 0;

adapter->vlan_tag[vid] = 0;
if (adapter->vlans_added <= adapter->max_vlans)
be_vid_config(adapter, false, 0);

return 0;
}

static void be_set_rx_mode(struct net_device *netdev)
Expand Down
21 changes: 16 additions & 5 deletions drivers/net/ethernet/ibm/ehea/ehea_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2114,24 +2114,27 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}

static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
static int ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
{
struct ehea_port *port = netdev_priv(dev);
struct ehea_adapter *adapter = port->adapter;
struct hcp_ehea_port_cb1 *cb1;
int index;
u64 hret;
int err = 0;

cb1 = (void *)get_zeroed_page(GFP_KERNEL);
if (!cb1) {
pr_err("no mem for cb1\n");
err = -ENOMEM;
goto out;
}

hret = ehea_h_query_ehea_port(adapter->handle, port->logical_port_id,
H_PORT_CB1, H_PORT_CB1_ALL, cb1);
if (hret != H_SUCCESS) {
pr_err("query_ehea_port failed\n");
err = -EINVAL;
goto out;
}

Expand All @@ -2140,31 +2143,36 @@ static void ehea_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)

hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id,
H_PORT_CB1, H_PORT_CB1_ALL, cb1);
if (hret != H_SUCCESS)
if (hret != H_SUCCESS) {
pr_err("modify_ehea_port failed\n");
err = -EINVAL;
}
out:
free_page((unsigned long)cb1);
return;
return err;
}

static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
static int ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
{
struct ehea_port *port = netdev_priv(dev);
struct ehea_adapter *adapter = port->adapter;
struct hcp_ehea_port_cb1 *cb1;
int index;
u64 hret;
int err = 0;

cb1 = (void *)get_zeroed_page(GFP_KERNEL);
if (!cb1) {
pr_err("no mem for cb1\n");
err = -ENOMEM;
goto out;
}

hret = ehea_h_query_ehea_port(adapter->handle, port->logical_port_id,
H_PORT_CB1, H_PORT_CB1_ALL, cb1);
if (hret != H_SUCCESS) {
pr_err("query_ehea_port failed\n");
err = -EINVAL;
goto out;
}

Expand All @@ -2173,10 +2181,13 @@ static void ehea_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)

hret = ehea_h_modify_ehea_port(adapter->handle, port->logical_port_id,
H_PORT_CB1, H_PORT_CB1_ALL, cb1);
if (hret != H_SUCCESS)
if (hret != H_SUCCESS) {
pr_err("modify_ehea_port failed\n");
err = -EINVAL;
}
out:
free_page((unsigned long)cb1);
return err;
}

int ehea_activate_qp(struct ehea_adapter *adapter, struct ehea_qp *qp)
Expand Down
14 changes: 9 additions & 5 deletions drivers/net/ethernet/intel/e1000/e1000_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
static bool e1000_vlan_used(struct e1000_adapter *adapter);
static void e1000_vlan_mode(struct net_device *netdev,
netdev_features_t features);
static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid);
static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid);
static void e1000_restore_vlan(struct e1000_adapter *adapter);

#ifdef CONFIG_PM
Expand Down Expand Up @@ -4604,7 +4604,7 @@ static void e1000_vlan_mode(struct net_device *netdev,
e1000_irq_enable(adapter);
}

static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
Expand All @@ -4613,7 +4613,7 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
if ((hw->mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
(vid == adapter->mng_vlan_id))
return;
return 0;

if (!e1000_vlan_used(adapter))
e1000_vlan_filter_on_off(adapter, true);
Expand All @@ -4625,9 +4625,11 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
e1000_write_vfta(hw, index, vfta);

set_bit(vid, adapter->active_vlans);

return 0;
}

static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
Expand All @@ -4648,6 +4650,8 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)

if (!e1000_vlan_used(adapter))
e1000_vlan_filter_on_off(adapter, false);

return 0;
}

static void e1000_restore_vlan(struct e1000_adapter *adapter)
Expand Down
12 changes: 8 additions & 4 deletions drivers/net/ethernet/intel/e1000e/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ static int e1000_clean(struct napi_struct *napi, int budget)
return work_done;
}

static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
static int e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
Expand All @@ -2532,7 +2532,7 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
if ((adapter->hw.mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN) &&
(vid == adapter->mng_vlan_id))
return;
return 0;

/* add VID to filter table */
if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER) {
Expand All @@ -2543,9 +2543,11 @@ static void e1000_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
}

set_bit(vid, adapter->active_vlans);

return 0;
}

static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
static int e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
{
struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
Expand All @@ -2556,7 +2558,7 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
(vid == adapter->mng_vlan_id)) {
/* release control to f/w */
e1000e_release_hw_control(adapter);
return;
return 0;
}

/* remove VID from filter table */
Expand All @@ -2568,6 +2570,8 @@ static void e1000_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
}

clear_bit(vid, adapter->active_vlans);

return 0;
}

/**
Expand Down
Loading

0 comments on commit 8e58613

Please sign in to comment.