Commit 8788fdc2 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: get rid of be_ctrl_info struct/abstraction

Currently only the be_ctrl_info struct ptr (instead of adapter) is
 passed to all the routines in be_cmds.c. Instead pass be_adapter
ptr to allow access to all its fields. Merge the contents of struct be_ctrl_info
into be_adapter. The resulting code is simpler.
Signed-off-by: default avatarSathya Perla <sathyap@serverengines.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f6d7c1b
...@@ -71,6 +71,8 @@ static inline char *nic_name(struct pci_dev *pdev) ...@@ -71,6 +71,8 @@ static inline char *nic_name(struct pci_dev *pdev)
#define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */ #define MAX_RX_POST BE_NAPI_WEIGHT /* Frags posted at a time */
#define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST) #define RX_FRAGS_REFILL_WM (RX_Q_LEN - MAX_RX_POST)
#define FW_VER_LEN 32
struct be_dma_mem { struct be_dma_mem {
void *va; void *va;
dma_addr_t dma; dma_addr_t dma;
...@@ -123,7 +125,6 @@ static inline void queue_tail_inc(struct be_queue_info *q) ...@@ -123,7 +125,6 @@ static inline void queue_tail_inc(struct be_queue_info *q)
index_inc(&q->tail, q->len); index_inc(&q->tail, q->len);
} }
struct be_eq_obj { struct be_eq_obj {
struct be_queue_info q; struct be_queue_info q;
char desc[32]; char desc[32];
...@@ -142,31 +143,6 @@ struct be_mcc_obj { ...@@ -142,31 +143,6 @@ struct be_mcc_obj {
struct be_queue_info cq; struct be_queue_info cq;
}; };
struct be_ctrl_info {
u8 __iomem *csr;
u8 __iomem *db; /* Door Bell */
u8 __iomem *pcicfg; /* PCI config space */
int pci_func;
/* Mbox used for cmd request/response */
spinlock_t mbox_lock; /* For serializing mbox cmds to BE card */
struct be_dma_mem mbox_mem;
/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
* is stored for freeing purpose */
struct be_dma_mem mbox_mem_alloced;
/* MCC Rings */
struct be_mcc_obj mcc_obj;
spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;
/* MCC Async callback */
void (*async_cb)(void *adapter, bool link_up);
void *adapter_ctxt;
};
#include "be_cmds.h"
struct be_drvr_stats { struct be_drvr_stats {
u32 be_tx_reqs; /* number of TX requests initiated */ u32 be_tx_reqs; /* number of TX requests initiated */
u32 be_tx_stops; /* number of times TX Q was stopped */ u32 be_tx_stops; /* number of times TX Q was stopped */
...@@ -234,8 +210,20 @@ struct be_adapter { ...@@ -234,8 +210,20 @@ struct be_adapter {
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *netdev; struct net_device *netdev;
/* Mbox, pci config, csr address information */ u8 __iomem *csr;
struct be_ctrl_info ctrl; u8 __iomem *db; /* Door Bell */
u8 __iomem *pcicfg; /* PCI config space */
int pci_func;
spinlock_t mbox_lock; /* For serializing mbox cmds to BE card */
struct be_dma_mem mbox_mem;
/* Mbox mem is adjusted to align to 16 bytes. The allocated addr
* is stored for freeing purpose */
struct be_dma_mem mbox_mem_alloced;
struct be_mcc_obj mcc_obj;
spinlock_t mcc_lock; /* For serializing mcc cmds to BE card */
spinlock_t mcc_cq_lock;
struct msix_entry msix_entries[BE_NUM_MSIX_VECTORS]; struct msix_entry msix_entries[BE_NUM_MSIX_VECTORS];
bool msix_enabled; bool msix_enabled;
...@@ -366,6 +354,7 @@ static inline u8 is_udp_pkt(struct sk_buff *skb) ...@@ -366,6 +354,7 @@ static inline u8 is_udp_pkt(struct sk_buff *skb)
return val; return val;
} }
extern void be_cq_notify(struct be_ctrl_info *ctrl, u16 qid, bool arm, extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
u16 num_popped); u16 num_popped);
extern void be_link_status_update(struct be_adapter *adapter, bool link_up);
#endif /* BE_H */ #endif /* BE_H */
This diff is collapsed.
...@@ -634,7 +634,6 @@ struct be_cmd_resp_link_status { ...@@ -634,7 +634,6 @@ struct be_cmd_resp_link_status {
} __packed; } __packed;
/******************** Get FW Version *******************/ /******************** Get FW Version *******************/
#define FW_VER_LEN 32
struct be_cmd_req_get_fw_version { struct be_cmd_req_get_fw_version {
struct be_cmd_req_hdr hdr; struct be_cmd_req_hdr hdr;
u8 rsvd0[FW_VER_LEN]; u8 rsvd0[FW_VER_LEN];
...@@ -697,52 +696,52 @@ struct be_cmd_resp_query_fw_cfg { ...@@ -697,52 +696,52 @@ struct be_cmd_resp_query_fw_cfg {
u32 rsvd[26]; u32 rsvd[26];
}; };
extern int be_pci_fnum_get(struct be_ctrl_info *ctrl); extern int be_pci_fnum_get(struct be_adapter *adapter);
extern int be_cmd_POST(struct be_ctrl_info *ctrl); extern int be_cmd_POST(struct be_adapter *adapter);
extern int be_cmd_mac_addr_query(struct be_ctrl_info *ctrl, u8 *mac_addr, extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
u8 type, bool permanent, u32 if_handle); u8 type, bool permanent, u32 if_handle);
extern int be_cmd_pmac_add(struct be_ctrl_info *ctrl, u8 *mac_addr, extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr,
u32 if_id, u32 *pmac_id); u32 if_id, u32 *pmac_id);
extern int be_cmd_pmac_del(struct be_ctrl_info *ctrl, u32 if_id, u32 pmac_id); extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, u32 pmac_id);
extern int be_cmd_if_create(struct be_ctrl_info *ctrl, u32 if_flags, u8 *mac, extern int be_cmd_if_create(struct be_adapter *adapter, u32 if_flags, u8 *mac,
bool pmac_invalid, u32 *if_handle, u32 *pmac_id); bool pmac_invalid, u32 *if_handle, u32 *pmac_id);
extern int be_cmd_if_destroy(struct be_ctrl_info *ctrl, u32 if_handle); extern int be_cmd_if_destroy(struct be_adapter *adapter, u32 if_handle);
extern int be_cmd_eq_create(struct be_ctrl_info *ctrl, extern int be_cmd_eq_create(struct be_adapter *adapter,
struct be_queue_info *eq, int eq_delay); struct be_queue_info *eq, int eq_delay);
extern int be_cmd_cq_create(struct be_ctrl_info *ctrl, extern int be_cmd_cq_create(struct be_adapter *adapter,
struct be_queue_info *cq, struct be_queue_info *eq, struct be_queue_info *cq, struct be_queue_info *eq,
bool sol_evts, bool no_delay, bool sol_evts, bool no_delay,
int num_cqe_dma_coalesce); int num_cqe_dma_coalesce);
extern int be_cmd_mccq_create(struct be_ctrl_info *ctrl, extern int be_cmd_mccq_create(struct be_adapter *adapter,
struct be_queue_info *mccq, struct be_queue_info *mccq,
struct be_queue_info *cq); struct be_queue_info *cq);
extern int be_cmd_txq_create(struct be_ctrl_info *ctrl, extern int be_cmd_txq_create(struct be_adapter *adapter,
struct be_queue_info *txq, struct be_queue_info *txq,
struct be_queue_info *cq); struct be_queue_info *cq);
extern int be_cmd_rxq_create(struct be_ctrl_info *ctrl, extern int be_cmd_rxq_create(struct be_adapter *adapter,
struct be_queue_info *rxq, u16 cq_id, struct be_queue_info *rxq, u16 cq_id,
u16 frag_size, u16 max_frame_size, u32 if_id, u16 frag_size, u16 max_frame_size, u32 if_id,
u32 rss); u32 rss);
extern int be_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q, extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
int type); int type);
extern int be_cmd_link_status_query(struct be_ctrl_info *ctrl, extern int be_cmd_link_status_query(struct be_adapter *adapter,
bool *link_up); bool *link_up);
extern int be_cmd_reset(struct be_ctrl_info *ctrl); extern int be_cmd_reset(struct be_adapter *adapter);
extern int be_cmd_get_stats(struct be_ctrl_info *ctrl, extern int be_cmd_get_stats(struct be_adapter *adapter,
struct be_dma_mem *nonemb_cmd); struct be_dma_mem *nonemb_cmd);
extern int be_cmd_get_fw_ver(struct be_ctrl_info *ctrl, char *fw_ver); extern int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver);
extern int be_cmd_modify_eqd(struct be_ctrl_info *ctrl, u32 eq_id, u32 eqd); extern int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd);
extern int be_cmd_vlan_config(struct be_ctrl_info *ctrl, u32 if_id, extern int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id,
u16 *vtag_array, u32 num, bool untagged, u16 *vtag_array, u32 num, bool untagged,
bool promiscuous); bool promiscuous);
extern int be_cmd_promiscuous_config(struct be_ctrl_info *ctrl, extern int be_cmd_promiscuous_config(struct be_adapter *adapter,
u8 port_num, bool en); u8 port_num, bool en);
extern int be_cmd_multicast_set(struct be_ctrl_info *ctrl, u32 if_id, extern int be_cmd_multicast_set(struct be_adapter *adapter, u32 if_id,
struct dev_mc_list *mc_list, u32 mc_count); struct dev_mc_list *mc_list, u32 mc_count);
extern int be_cmd_set_flow_control(struct be_ctrl_info *ctrl, extern int be_cmd_set_flow_control(struct be_adapter *adapter,
u32 tx_fc, u32 rx_fc); u32 tx_fc, u32 rx_fc);
extern int be_cmd_get_flow_control(struct be_ctrl_info *ctrl, extern int be_cmd_get_flow_control(struct be_adapter *adapter,
u32 *tx_fc, u32 *rx_fc); u32 *tx_fc, u32 *rx_fc);
extern int be_cmd_query_fw_cfg(struct be_ctrl_info *ctrl, u32 *port_num); extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num);
extern void be_process_mcc(struct be_ctrl_info *ctrl); extern void be_process_mcc(struct be_adapter *adapter);
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
#include "be.h" #include "be.h"
#include "be_cmds.h"
#include <linux/ethtool.h> #include <linux/ethtool.h>
struct be_ethtool_stat { struct be_ethtool_stat {
...@@ -148,7 +149,6 @@ static int ...@@ -148,7 +149,6 @@ static int
be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_ctrl_info *ctrl = &adapter->ctrl;
struct be_eq_obj *rx_eq = &adapter->rx_eq; struct be_eq_obj *rx_eq = &adapter->rx_eq;
struct be_eq_obj *tx_eq = &adapter->tx_eq; struct be_eq_obj *tx_eq = &adapter->tx_eq;
u32 tx_max, tx_min, tx_cur; u32 tx_max, tx_min, tx_cur;
...@@ -176,7 +176,7 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) ...@@ -176,7 +176,7 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
if (tx_cur > BE_MAX_EQD) if (tx_cur > BE_MAX_EQD)
tx_cur = BE_MAX_EQD; tx_cur = BE_MAX_EQD;
if (tx_eq->cur_eqd != tx_cur) { if (tx_eq->cur_eqd != tx_cur) {
status = be_cmd_modify_eqd(ctrl, tx_eq->q.id, tx_cur); status = be_cmd_modify_eqd(adapter, tx_eq->q.id, tx_cur);
if (!status) if (!status)
tx_eq->cur_eqd = tx_cur; tx_eq->cur_eqd = tx_cur;
} }
...@@ -196,7 +196,8 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce) ...@@ -196,7 +196,8 @@ be_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
if (rx_cur > BE_MAX_EQD) if (rx_cur > BE_MAX_EQD)
rx_cur = BE_MAX_EQD; rx_cur = BE_MAX_EQD;
if (rx_eq->cur_eqd != rx_cur) { if (rx_eq->cur_eqd != rx_cur) {
status = be_cmd_modify_eqd(ctrl, rx_eq->q.id, rx_cur); status = be_cmd_modify_eqd(adapter, rx_eq->q.id,
rx_cur);
if (!status) if (!status)
rx_eq->cur_eqd = rx_cur; rx_eq->cur_eqd = rx_cur;
} }
...@@ -310,8 +311,7 @@ be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) ...@@ -310,8 +311,7 @@ be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
be_cmd_get_flow_control(&adapter->ctrl, &ecmd->tx_pause, be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause);
&ecmd->rx_pause);
ecmd->autoneg = 0; ecmd->autoneg = 0;
} }
...@@ -324,7 +324,7 @@ be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) ...@@ -324,7 +324,7 @@ be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd)
if (ecmd->autoneg != 0) if (ecmd->autoneg != 0)
return -EINVAL; return -EINVAL;
status = be_cmd_set_flow_control(&adapter->ctrl, ecmd->tx_pause, status = be_cmd_set_flow_control(adapter, ecmd->tx_pause,
ecmd->rx_pause); ecmd->rx_pause);
if (!status) if (!status)
dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); dev_warn(&adapter->pdev->dev, "Pause param set failed.\n");
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment