Skip to content

Commit

Permalink
enic: Clean up: Organize devcmd wrapper routines
Browse files Browse the repository at this point in the history
Organize the wrapper routines for firmware devcmds into a separate file.

Signed-off-by: Christian Benvenuti <benve@cisco.com>
Signed-off-by: Vasanthy Kolluri <vkolluri@cisco.com>
Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
Signed-off-by: David Wang <dwang2@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vasanthy Kolluri authored and David S. Miller committed Feb 7, 2011
1 parent 8a37555 commit 5198746
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 208 deletions.
2 changes: 1 addition & 1 deletion drivers/net/enic/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
obj-$(CONFIG_ENIC) := enic.o

enic-y := enic_main.o vnic_cq.o vnic_intr.o vnic_wq.o \
enic_res.o vnic_dev.o vnic_rq.o vnic_vic.o
enic_res.o enic_dev.o vnic_dev.o vnic_rq.o vnic_vic.o

2 changes: 1 addition & 1 deletion drivers/net/enic/enic.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define DRV_NAME "enic"
#define DRV_DESCRIPTION "Cisco VIC Ethernet NIC Driver"
#define DRV_VERSION "2.1.1.2a"
#define DRV_VERSION "2.1.1.3"
#define DRV_COPYRIGHT "Copyright 2008-2011 Cisco Systems, Inc"

#define ENIC_BARS_MAX 6
Expand Down
230 changes: 230 additions & 0 deletions drivers/net/enic/enic_dev.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
/*
* Copyright 2011 Cisco Systems, Inc. All rights reserved.
*
* This program is free software; you may redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include <linux/pci.h>
#include <linux/etherdevice.h>

#include "vnic_dev.h"
#include "vnic_vic.h"
#include "enic_res.h"
#include "enic.h"
#include "enic_dev.h"

int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_fw_info(enic->vdev, fw_info);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_stats_dump(enic->vdev, vstats);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_add_station_addr(struct enic *enic)
{
int err = 0;

if (is_valid_ether_addr(enic->netdev->dev_addr)) {
spin_lock(&enic->devcmd_lock);
err = vnic_dev_add_addr(enic->vdev, enic->netdev->dev_addr);
spin_unlock(&enic->devcmd_lock);
}

return err;
}

int enic_dev_del_station_addr(struct enic *enic)
{
int err = 0;

if (is_valid_ether_addr(enic->netdev->dev_addr)) {
spin_lock(&enic->devcmd_lock);
err = vnic_dev_del_addr(enic->vdev, enic->netdev->dev_addr);
spin_unlock(&enic->devcmd_lock);
}

return err;
}

int enic_dev_packet_filter(struct enic *enic, int directed, int multicast,
int broadcast, int promisc, int allmulti)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_packet_filter(enic->vdev, directed,
multicast, broadcast, promisc, allmulti);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_add_addr(struct enic *enic, u8 *addr)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_add_addr(enic->vdev, addr);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_del_addr(struct enic *enic, u8 *addr)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_del_addr(enic->vdev, addr);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_hw_version(struct enic *enic, enum vnic_dev_hw_version *hw_ver)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_hw_version(enic->vdev, hw_ver);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_notify_unset(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_notify_unset(enic->vdev);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_hang_notify(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_hang_notify(enic->vdev);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_set_ig_vlan_rewrite_mode(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_set_ig_vlan_rewrite_mode(enic->vdev,
IG_VLAN_REWRITE_MODE_PRIORITY_TAG_DEFAULT_VLAN);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_enable(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_enable_wait(enic->vdev);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_disable(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_disable(enic->vdev);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_vnic_dev_deinit(struct enic *enic)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_deinit(enic->vdev);
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_init_prov(struct enic *enic, struct vic_provinfo *vp)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_init_prov(enic->vdev,
(u8 *)vp, vic_provinfo_size(vp));
spin_unlock(&enic->devcmd_lock);

return err;
}

int enic_dev_init_done(struct enic *enic, int *done, int *error)
{
int err;

spin_lock(&enic->devcmd_lock);
err = vnic_dev_init_done(enic->vdev, done, error);
spin_unlock(&enic->devcmd_lock);

return err;
}

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

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

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

spin_lock(&enic->devcmd_lock);
enic_del_vlan(enic, vid);
spin_unlock(&enic->devcmd_lock);
}
42 changes: 42 additions & 0 deletions drivers/net/enic/enic_dev.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2011 Cisco Systems, Inc. All rights reserved.
*
* This program is free software; you may redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#ifndef _ENIC_DEV_H_
#define _ENIC_DEV_H_

int enic_dev_fw_info(struct enic *enic, struct vnic_devcmd_fw_info **fw_info);
int enic_dev_stats_dump(struct enic *enic, struct vnic_stats **vstats);
int enic_dev_add_station_addr(struct enic *enic);
int enic_dev_del_station_addr(struct enic *enic);
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_dev_hw_version(struct enic *enic, enum vnic_dev_hw_version *hw_ver);
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);
int enic_dev_enable(struct enic *enic);
int enic_dev_disable(struct enic *enic);
int enic_vnic_dev_deinit(struct enic *enic);
int enic_dev_init_prov(struct enic *enic, struct vic_provinfo *vp);
int enic_dev_init_done(struct enic *enic, int *done, int *error);

#endif /* _ENIC_DEV_H_ */
Loading

0 comments on commit 5198746

Please sign in to comment.