Commit 1de899d3 authored by Sucheta Chakraborty's avatar Sucheta Chakraborty Committed by David S. Miller

qlcnic: dcb code cleanup and refactoring.

o Move dcb specific function definitions to dcb files.
o Move dcb specific variables to qlcnic_dcb structure.
Signed-off-by: default avatarSucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: default avatarHimanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4c776aad
...@@ -961,8 +961,6 @@ struct qlcnic_ipaddr { ...@@ -961,8 +961,6 @@ struct qlcnic_ipaddr {
#define __QLCNIC_SRIOV_CAPABLE 11 #define __QLCNIC_SRIOV_CAPABLE 11
#define __QLCNIC_MBX_POLL_ENABLE 12 #define __QLCNIC_MBX_POLL_ENABLE 12
#define __QLCNIC_DIAG_MODE 13 #define __QLCNIC_DIAG_MODE 13
#define __QLCNIC_DCB_STATE 14
#define __QLCNIC_DCB_IN_AEN 15
#define QLCNIC_INTERRUPT_TEST 1 #define QLCNIC_INTERRUPT_TEST 1
#define QLCNIC_LOOPBACK_TEST 2 #define QLCNIC_LOOPBACK_TEST 2
...@@ -2116,98 +2114,4 @@ static inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter) ...@@ -2116,98 +2114,4 @@ static inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter)
return status; return status;
} }
static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->get_hw_capability)
return dcb->ops->get_hw_capability(adapter);
return 0;
}
static inline void qlcnic_dcb_free(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->free)
dcb->ops->free(adapter);
}
static inline int qlcnic_dcb_attach(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->attach)
return dcb->ops->attach(adapter);
return 0;
}
static inline int
qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter, char *buf)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->query_hw_capability)
return dcb->ops->query_hw_capability(adapter, buf);
return 0;
}
static inline void qlcnic_dcb_get_info(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->get_info)
dcb->ops->get_info(adapter);
}
static inline int
qlcnic_dcb_query_cee_param(struct qlcnic_adapter *adapter, char *buf, u8 type)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->query_cee_param)
return dcb->ops->query_cee_param(adapter, buf, type);
return 0;
}
static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->get_cee_cfg)
return dcb->ops->get_cee_cfg(adapter);
return 0;
}
static inline void
qlcnic_dcb_register_aen(struct qlcnic_adapter *adapter, u8 flag)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->register_aen)
dcb->ops->register_aen(adapter, flag);
}
static inline void qlcnic_dcb_handle_aen(struct qlcnic_adapter *adapter,
void *msg)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->handle_aen)
dcb->ops->handle_aen(adapter, msg);
}
static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_adapter *adapter)
{
struct qlcnic_dcb *dcb = adapter->dcb;
if (dcb && dcb->ops->init_dcbnl_ops)
dcb->ops->init_dcbnl_ops(adapter);
}
#endif /* __QLCNIC_H_ */ #endif /* __QLCNIC_H_ */
...@@ -902,7 +902,7 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter) ...@@ -902,7 +902,7 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter)
QLCNIC_MBX_RSP(event[0])); QLCNIC_MBX_RSP(event[0]));
break; break;
case QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT: case QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT:
qlcnic_dcb_handle_aen(adapter, (void *)&event[1]); qlcnic_dcb_aen_handler(adapter->dcb, (void *)&event[1]);
break; break;
default: default:
dev_dbg(&adapter->pdev->dev, "Unsupported AEN:0x%x.\n", dev_dbg(&adapter->pdev->dev, "Unsupported AEN:0x%x.\n",
......
...@@ -636,7 +636,7 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter) ...@@ -636,7 +636,7 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter)
if (adapter->portnum == 0) if (adapter->portnum == 0)
qlcnic_set_drv_version(adapter); qlcnic_set_drv_version(adapter);
qlcnic_dcb_get_info(adapter); qlcnic_dcb_get_info(adapter->dcb);
qlcnic_83xx_idc_attach_driver(adapter); qlcnic_83xx_idc_attach_driver(adapter);
return 0; return 0;
...@@ -2174,6 +2174,7 @@ static int qlcnic_83xx_get_fw_info(struct qlcnic_adapter *adapter) ...@@ -2174,6 +2174,7 @@ static int qlcnic_83xx_get_fw_info(struct qlcnic_adapter *adapter)
int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
{ {
struct qlcnic_hardware_context *ahw = adapter->ahw; struct qlcnic_hardware_context *ahw = adapter->ahw;
struct qlcnic_dcb *dcb;
int err = 0; int err = 0;
ahw->msix_supported = !!qlcnic_use_msi_x; ahw->msix_supported = !!qlcnic_use_msi_x;
...@@ -2231,8 +2232,10 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) ...@@ -2231,8 +2232,10 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac)
if (err) if (err)
goto disable_mbx_intr; goto disable_mbx_intr;
if (adapter->dcb && qlcnic_dcb_attach(adapter)) dcb = adapter->dcb;
qlcnic_clear_dcb_ops(adapter);
if (dcb && qlcnic_dcb_attach(dcb))
qlcnic_clear_dcb_ops(dcb);
/* Periodically monitor device status */ /* Periodically monitor device status */
qlcnic_83xx_idc_poll_dev_state(&adapter->fw_work.work); qlcnic_83xx_idc_poll_dev_state(&adapter->fw_work.work);
......
...@@ -8,26 +8,29 @@ ...@@ -8,26 +8,29 @@
#ifndef __QLCNIC_DCBX_H #ifndef __QLCNIC_DCBX_H
#define __QLCNIC_DCBX_H #define __QLCNIC_DCBX_H
void qlcnic_clear_dcb_ops(struct qlcnic_adapter *); #define QLCNIC_DCB_STATE 0
#define QLCNIC_DCB_AEN_MODE 1
#ifdef CONFIG_QLCNIC_DCB #ifdef CONFIG_QLCNIC_DCB
int __qlcnic_register_dcb(struct qlcnic_adapter *); int qlcnic_register_dcb(struct qlcnic_adapter *);
#else #else
static inline int __qlcnic_register_dcb(struct qlcnic_adapter *adapter) static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
{ return 0; } { return 0; }
#endif #endif
struct qlcnic_dcb;
struct qlcnic_dcb_ops { struct qlcnic_dcb_ops {
void (*init_dcbnl_ops) (struct qlcnic_adapter *); int (*query_hw_capability) (struct qlcnic_dcb *, char *);
void (*free) (struct qlcnic_adapter *); int (*get_hw_capability) (struct qlcnic_dcb *);
int (*attach) (struct qlcnic_adapter *); int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
int (*query_hw_capability) (struct qlcnic_adapter *, char *); void (*init_dcbnl_ops) (struct qlcnic_dcb *);
int (*get_hw_capability) (struct qlcnic_adapter *); int (*register_aen) (struct qlcnic_dcb *, bool);
void (*get_info) (struct qlcnic_adapter *); void (*aen_handler) (struct qlcnic_dcb *, void *);
int (*query_cee_param) (struct qlcnic_adapter *, char *, u8); int (*get_cee_cfg) (struct qlcnic_dcb *);
int (*get_cee_cfg) (struct qlcnic_adapter *); void (*get_info) (struct qlcnic_dcb *);
int (*register_aen) (struct qlcnic_adapter *, bool); int (*attach) (struct qlcnic_dcb *);
void (*handle_aen) (struct qlcnic_adapter *, void *); void (*free) (struct qlcnic_dcb *);
}; };
struct qlcnic_dcb { struct qlcnic_dcb {
...@@ -37,5 +40,85 @@ struct qlcnic_dcb { ...@@ -37,5 +40,85 @@ struct qlcnic_dcb {
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct qlcnic_dcb_ops *ops; struct qlcnic_dcb_ops *ops;
struct qlcnic_dcb_cfg *cfg; struct qlcnic_dcb_cfg *cfg;
unsigned long state;
}; };
static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
{
kfree(dcb);
dcb = NULL;
}
static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->get_hw_capability)
return dcb->ops->get_hw_capability(dcb);
return 0;
}
static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->free)
dcb->ops->free(dcb);
}
static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->attach)
return dcb->ops->attach(dcb);
return 0;
}
static inline int
qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
{
if (dcb && dcb->ops->query_hw_capability)
return dcb->ops->query_hw_capability(dcb, buf);
return 0;
}
static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->get_info)
dcb->ops->get_info(dcb);
}
static inline int
qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
{
if (dcb && dcb->ops->query_cee_param)
return dcb->ops->query_cee_param(dcb, buf, type);
return 0;
}
static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->get_cee_cfg)
return dcb->ops->get_cee_cfg(dcb);
return 0;
}
static inline void
qlcnic_dcb_register_aen(struct qlcnic_dcb *dcb, u8 flag)
{
if (dcb && dcb->ops->register_aen)
dcb->ops->register_aen(dcb, flag);
}
static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
{
if (dcb && dcb->ops->aen_handler)
dcb->ops->aen_handler(dcb, msg);
}
static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
{
if (dcb && dcb->ops->init_dcbnl_ops)
dcb->ops->init_dcbnl_ops(dcb);
}
#endif #endif
...@@ -1011,7 +1011,7 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index, ...@@ -1011,7 +1011,7 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index,
} }
break; break;
case QLCNIC_C2H_OPCODE_GET_DCB_AEN: case QLCNIC_C2H_OPCODE_GET_DCB_AEN:
qlcnic_dcb_handle_aen(adapter, (void *)&msg); qlcnic_dcb_aen_handler(adapter->dcb, (void *)&msg);
break; break;
default: default:
break; break;
......
...@@ -2071,7 +2071,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev, ...@@ -2071,7 +2071,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev,
return err; return err;
} }
qlcnic_dcb_init_dcbnl_ops(adapter); qlcnic_dcb_init_dcbnl_ops(adapter->dcb);
return 0; return 0;
} }
...@@ -2166,17 +2166,6 @@ void qlcnic_set_drv_version(struct qlcnic_adapter *adapter) ...@@ -2166,17 +2166,6 @@ void qlcnic_set_drv_version(struct qlcnic_adapter *adapter)
qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd); qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd);
} }
static int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
{
return __qlcnic_register_dcb(adapter);
}
void qlcnic_clear_dcb_ops(struct qlcnic_adapter *adapter)
{
kfree(adapter->dcb);
adapter->dcb = NULL;
}
static int static int
qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
...@@ -2185,6 +2174,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2185,6 +2174,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
struct qlcnic_hardware_context *ahw; struct qlcnic_hardware_context *ahw;
int err, pci_using_dac = -1; int err, pci_using_dac = -1;
char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */ char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */
struct qlcnic_dcb *dcb;
if (pdev->is_virtfn) if (pdev->is_virtfn)
return -ENODEV; return -ENODEV;
...@@ -2305,8 +2295,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2305,8 +2295,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
adapter->flags |= QLCNIC_NEED_FLR; adapter->flags |= QLCNIC_NEED_FLR;
if (adapter->dcb && qlcnic_dcb_attach(adapter)) dcb = adapter->dcb;
qlcnic_clear_dcb_ops(adapter);
if (dcb && qlcnic_dcb_attach(dcb))
qlcnic_clear_dcb_ops(dcb);
} else if (qlcnic_83xx_check(adapter)) { } else if (qlcnic_83xx_check(adapter)) {
adapter->max_drv_tx_rings = 1; adapter->max_drv_tx_rings = 1;
...@@ -2451,7 +2443,7 @@ static void qlcnic_remove(struct pci_dev *pdev) ...@@ -2451,7 +2443,7 @@ static void qlcnic_remove(struct pci_dev *pdev)
qlcnic_cancel_idc_work(adapter); qlcnic_cancel_idc_work(adapter);
ahw = adapter->ahw; ahw = adapter->ahw;
qlcnic_dcb_free(adapter); qlcnic_dcb_free(adapter->dcb);
unregister_netdev(netdev); unregister_netdev(netdev);
qlcnic_sriov_cleanup(adapter); qlcnic_sriov_cleanup(adapter);
...@@ -3329,7 +3321,7 @@ qlcnic_attach_work(struct work_struct *work) ...@@ -3329,7 +3321,7 @@ qlcnic_attach_work(struct work_struct *work)
return; return;
} }
attach: attach:
qlcnic_dcb_get_info(adapter); qlcnic_dcb_get_info(adapter->dcb);
if (netif_running(netdev)) { if (netif_running(netdev)) {
if (qlcnic_up(adapter, netdev)) if (qlcnic_up(adapter, netdev))
......
...@@ -500,6 +500,7 @@ static int qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter) ...@@ -500,6 +500,7 @@ static int qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter)
static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter, static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter,
int pci_using_dac) int pci_using_dac)
{ {
struct qlcnic_dcb *dcb;
int err; int err;
INIT_LIST_HEAD(&adapter->vf_mc_list); INIT_LIST_HEAD(&adapter->vf_mc_list);
...@@ -533,8 +534,10 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter, ...@@ -533,8 +534,10 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter,
if (err) if (err)
goto err_out_send_channel_term; goto err_out_send_channel_term;
if (adapter->dcb && qlcnic_dcb_attach(adapter)) dcb = adapter->dcb;
qlcnic_clear_dcb_ops(adapter);
if (dcb && qlcnic_dcb_attach(dcb))
qlcnic_clear_dcb_ops(dcb);
err = qlcnic_setup_netdev(adapter, adapter->netdev, pci_using_dac); err = qlcnic_setup_netdev(adapter, adapter->netdev, pci_using_dac);
if (err) if (err)
...@@ -1577,7 +1580,7 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter) ...@@ -1577,7 +1580,7 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter)
if (err) if (err)
goto err_out_term_channel; goto err_out_term_channel;
qlcnic_dcb_get_info(adapter); qlcnic_dcb_get_info(adapter->dcb);
return 0; return 0;
......
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