Commit 319ecf12 authored by Sony Chacko's avatar Sony Chacko Committed by David S. Miller

qlcnic: 83xx sysfs routines

Add 83xx sysfs interface routines
Update 82xx sysfs interface routines
Signed-off-by: default avatarAnirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: default avatarSony Chacko <sony.chacko@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13159183
......@@ -1429,8 +1429,8 @@ int qlcnic_reset_context(struct qlcnic_adapter *);
void qlcnic_diag_free_res(struct net_device *netdev, int max_sds_rings);
int qlcnic_diag_alloc_res(struct net_device *netdev, int test);
netdev_tx_t qlcnic_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data);
int qlcnic_validate_max_rss(struct net_device *netdev, u8, u8);
int qlcnic_set_max_rss(struct qlcnic_adapter *, u8, size_t);
int qlcnic_validate_max_rss(u8, u8);
void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter);
int qlcnic_enable_msix(struct qlcnic_adapter *, u32);
......@@ -1468,6 +1468,13 @@ void qlcnic_set_vlan_config(struct qlcnic_adapter *,
struct qlcnic_esw_func_cfg *);
void qlcnic_set_eswitch_port_features(struct qlcnic_adapter *,
struct qlcnic_esw_func_cfg *);
void __qlcnic_down(struct qlcnic_adapter *, struct net_device *);
void qlcnic_detach(struct qlcnic_adapter *);
void qlcnic_teardown_intr(struct qlcnic_adapter *);
int qlcnic_attach(struct qlcnic_adapter *);
int __qlcnic_up(struct qlcnic_adapter *, struct net_device *);
void qlcnic_restore_indev_addr(struct net_device *, unsigned long);
/*
* QLOGIC Board information
......
......@@ -242,6 +242,8 @@ static struct qlcnic_hardware_ops qlcnic_83xx_hw_ops = {
.get_func_no = qlcnic_83xx_get_func_no,
.api_lock = qlcnic_83xx_cam_lock,
.api_unlock = qlcnic_83xx_cam_unlock,
.add_sysfs = qlcnic_83xx_add_sysfs,
.remove_sysfs = qlcnic_83xx_remove_sysfs,
.process_lb_rcv_ring_diag = qlcnic_83xx_process_rcv_ring_diag,
.create_rx_ctx = qlcnic_83xx_create_rx_ctx,
.create_tx_ctx = qlcnic_83xx_create_tx_ctx,
......@@ -1154,6 +1156,64 @@ int qlcnic_83xx_create_tx_ctx(struct qlcnic_adapter *adapter,
return err;
}
int qlcnic_83xx_config_led(struct qlcnic_adapter *adapter, u32 state,
u32 beacon)
{
struct qlcnic_cmd_args cmd;
u32 mbx_in;
int i, status = 0;
if (state) {
/* Get LED configuration */
qlcnic_alloc_mbx_args(&cmd, adapter,
QLCNIC_CMD_GET_LED_CONFIG);
status = qlcnic_issue_cmd(adapter, &cmd);
if (status) {
dev_err(&adapter->pdev->dev,
"Get led config failed.\n");
goto mbx_err;
} else {
for (i = 0; i < 4; i++)
adapter->ahw->mbox_reg[i] = cmd.rsp.arg[i+1];
}
qlcnic_free_mbx_args(&cmd);
/* Set LED Configuration */
mbx_in = (LSW(QLC_83XX_LED_CONFIG) << 16) |
LSW(QLC_83XX_LED_CONFIG);
qlcnic_alloc_mbx_args(&cmd, adapter,
QLCNIC_CMD_SET_LED_CONFIG);
cmd.req.arg[1] = mbx_in;
cmd.req.arg[2] = mbx_in;
cmd.req.arg[3] = mbx_in;
if (beacon)
cmd.req.arg[4] = QLC_83XX_ENABLE_BEACON;
status = qlcnic_issue_cmd(adapter, &cmd);
if (status) {
dev_err(&adapter->pdev->dev,
"Set led config failed.\n");
}
mbx_err:
qlcnic_free_mbx_args(&cmd);
return status;
} else {
/* Restoring default LED configuration */
qlcnic_alloc_mbx_args(&cmd, adapter,
QLCNIC_CMD_SET_LED_CONFIG);
cmd.req.arg[1] = adapter->ahw->mbox_reg[0];
cmd.req.arg[2] = adapter->ahw->mbox_reg[1];
cmd.req.arg[3] = adapter->ahw->mbox_reg[2];
if (beacon)
cmd.req.arg[4] = adapter->ahw->mbox_reg[3];
status = qlcnic_issue_cmd(adapter, &cmd);
if (status)
dev_err(&adapter->pdev->dev,
"Restoring led config failed.\n");
qlcnic_free_mbx_args(&cmd);
return status;
}
}
void qlcnic_83xx_register_nic_idc_func(struct qlcnic_adapter *adapter,
int enable)
{
......
......@@ -189,6 +189,8 @@ void qlcnic_83xx_get_func_no(struct qlcnic_adapter *);
int qlcnic_83xx_cam_lock(struct qlcnic_adapter *);
void qlcnic_83xx_cam_unlock(struct qlcnic_adapter *);
int qlcnic_send_ctrl_op(struct qlcnic_adapter *, struct qlcnic_cmd_args *, u32);
void qlcnic_83xx_add_sysfs(struct qlcnic_adapter *);
void qlcnic_83xx_remove_sysfs(struct qlcnic_adapter *);
void qlcnic_83xx_write_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
void qlcnic_83xx_read_crb(struct qlcnic_adapter *, char *, loff_t, size_t);
int qlcnic_83xx_rd_reg_indirect(struct qlcnic_adapter *, ulong);
......@@ -209,6 +211,7 @@ int qlcnic_83xx_napi_add(struct qlcnic_adapter *, struct net_device *);
void qlcnic_83xx_napi_del(struct qlcnic_adapter *);
void qlcnic_83xx_napi_enable(struct qlcnic_adapter *);
void qlcnic_83xx_napi_disable(struct qlcnic_adapter *);
int qlcnic_83xx_config_led(struct qlcnic_adapter *, u32, u32);
void qlcnic_ind_wr(struct qlcnic_adapter *, u32, u32);
int qlcnic_ind_rd(struct qlcnic_adapter *, u32);
void qlcnic_83xx_get_stats(struct qlcnic_adapter *,
......
......@@ -529,11 +529,11 @@ static int qlcnic_set_channels(struct net_device *dev,
channel->tx_count != channel->max_tx)
return -EINVAL;
err = qlcnic_validate_max_rss(dev, channel->max_rx, channel->rx_count);
err = qlcnic_validate_max_rss(channel->max_rx, channel->rx_count);
if (err)
return err;
err = qlcnic_set_max_rss(adapter, channel->rx_count);
err = qlcnic_set_max_rss(adapter, channel->rx_count, 0);
netdev_info(dev, "allocated 0x%x sds rings\n",
adapter->max_sds_rings);
return err;
......
......@@ -82,7 +82,6 @@ static irqreturn_t qlcnic_msix_intr(int irq, void *data);
static irqreturn_t qlcnic_msix_tx_intr(int irq, void *data);
static struct net_device_stats *qlcnic_get_stats(struct net_device *netdev);
static void qlcnic_restore_indev_addr(struct net_device *dev, unsigned long);
static int qlcnic_start_firmware(struct qlcnic_adapter *);
static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter);
......@@ -181,6 +180,7 @@ static const struct qlcnic_board_info qlcnic_boards[] = {
};
#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(qlcnic_boards)
#define QLC_MAX_SDS_RINGS 8
static const
struct qlcnic_legacy_intr_set legacy_intr[] = QLCNIC_LEGACY_INTR_CONFIG;
......@@ -451,8 +451,7 @@ int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter, u8 num_intr)
return 0;
}
static void
qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
void qlcnic_teardown_intr(struct qlcnic_adapter *adapter)
{
if (adapter->flags & QLCNIC_MSIX_ENABLED)
pci_disable_msix(adapter->pdev);
......@@ -1244,8 +1243,7 @@ qlcnic_free_irq(struct qlcnic_adapter *adapter)
}
}
static int
__qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
int __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
{
int ring;
u32 capab2;
......@@ -1310,8 +1308,7 @@ static int qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev)
return err;
}
static void
__qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
{
if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
return;
......@@ -1353,7 +1350,7 @@ qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev)
}
static int
int
qlcnic_attach(struct qlcnic_adapter *adapter)
{
struct net_device *netdev = adapter->netdev;
......@@ -1399,8 +1396,7 @@ qlcnic_attach(struct qlcnic_adapter *adapter)
return err;
}
static void
qlcnic_detach(struct qlcnic_adapter *adapter)
void qlcnic_detach(struct qlcnic_adapter *adapter)
{
if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC)
return;
......@@ -2055,14 +2051,8 @@ qlcnic_resume(struct pci_dev *pdev)
static int qlcnic_open(struct net_device *netdev)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
u32 state = QLCRD32(adapter, QLCNIC_CRB_DEV_STATE);
int err;
if (state == QLCNIC_DEV_FAILED || (state == QLCNIC_DEV_BADBAD)) {
netdev_err(netdev, "Device in FAILED state\n");
return -EIO;
}
netif_carrier_off(netdev);
err = qlcnic_attach(adapter);
......@@ -3092,33 +3082,38 @@ qlcnicvf_start_firmware(struct qlcnic_adapter *adapter)
return err;
}
int qlcnic_validate_max_rss(struct net_device *netdev, u8 max_hw, u8 val)
int qlcnic_validate_max_rss(u8 max_hw, u8 val)
{
if (!qlcnic_use_msi_x && !qlcnic_use_msi) {
netdev_info(netdev, "no msix or msi support, hence no rss\n");
return -EINVAL;
u32 max_allowed;
if (max_hw > QLC_MAX_SDS_RINGS) {
max_hw = QLC_MAX_SDS_RINGS;
pr_info("max rss reset to %d\n", QLC_MAX_SDS_RINGS);
}
if ((val > max_hw) || (val < 2) || !is_power_of_2(val)) {
netdev_info(netdev, "rss_ring valid range [2 - %x] in "
" powers of 2\n", max_hw);
max_allowed = rounddown_pow_of_two(min_t(int, max_hw,
num_online_cpus()));
if ((val > max_allowed) || (val < 2) || !is_power_of_2(val)) {
pr_info("rss_ring valid range [2 - %x] in powers of 2\n",
max_allowed);
return -EINVAL;
}
return 0;
}
int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data)
int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data, size_t len)
{
int err;
struct net_device *netdev = adapter->netdev;
rtnl_lock();
if (test_bit(__QLCNIC_RESETTING, &adapter->state))
return -EBUSY;
netif_device_detach(netdev);
if (netif_running(netdev))
__qlcnic_down(adapter, netdev);
if (qlcnic_83xx_check(adapter)) {
if (qlcnic_82xx_check(adapter)) {
if (adapter->flags & QLCNIC_MSIX_ENABLED)
qlcnic_83xx_config_intrpt(adapter, 0);
qlcnic_83xx_free_mbx_intr(adapter);
......@@ -3126,7 +3121,7 @@ int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data)
qlcnic_detach(adapter);
qlcnic_teardown_intr(adapter);
err = adapter->ahw->hw_ops->setup_intr(adapter, data);
err = qlcnic_setup_intr(adapter, data);
if (err)
dev_err(&adapter->pdev->dev,
"failed setting max_rss; rss disabled\n");
......@@ -3149,10 +3144,10 @@ int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data)
goto done;
qlcnic_restore_indev_addr(netdev, NETDEV_UP);
}
err = len;
done:
netif_device_attach(netdev);
clear_bit(__QLCNIC_RESETTING, &adapter->state);
rtnl_unlock();
return err;
}
......@@ -3188,8 +3183,7 @@ qlcnic_config_indev_addr(struct qlcnic_adapter *adapter,
in_dev_put(indev);
}
static void
qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
void qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
{
struct qlcnic_adapter *adapter = netdev_priv(netdev);
struct net_device *dev;
......
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