diff options
| author | Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> | 2011-08-29 08:50:30 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-08-29 22:52:50 -0400 |
| commit | 728a98b831eecada40b36df53420d57e9292c880 (patch) | |
| tree | e4bac789f65990bc6bcc5e82cd71f6a32ceca732 | |
| parent | 9254b751492c7fc08497a5c0e0cd668ddd269ea2 (diff) | |
qlcnic: add beacon test support.
Beacon test flashes both port LEDs instead of just 1 LED of a port.
Updated driver version to 5.0.23.
Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Sony Chacko <sony.chacko@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 10 | ||||
| -rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | 5 | ||||
| -rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 95 |
3 files changed, 108 insertions, 2 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index 2a3e552e9ffb..04c70153833f 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | |||
| @@ -36,8 +36,8 @@ | |||
| 36 | 36 | ||
| 37 | #define _QLCNIC_LINUX_MAJOR 5 | 37 | #define _QLCNIC_LINUX_MAJOR 5 |
| 38 | #define _QLCNIC_LINUX_MINOR 0 | 38 | #define _QLCNIC_LINUX_MINOR 0 |
| 39 | #define _QLCNIC_LINUX_SUBVERSION 22 | 39 | #define _QLCNIC_LINUX_SUBVERSION 23 |
| 40 | #define QLCNIC_LINUX_VERSIONID "5.0.22" | 40 | #define QLCNIC_LINUX_VERSIONID "5.0.23" |
| 41 | #define QLCNIC_DRV_IDC_VER 0x01 | 41 | #define QLCNIC_DRV_IDC_VER 0x01 |
| 42 | #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ | 42 | #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ |
| 43 | (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) | 43 | (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) |
| @@ -457,6 +457,8 @@ struct qlcnic_hardware_context { | |||
| 457 | u16 port_type; | 457 | u16 port_type; |
| 458 | u16 board_type; | 458 | u16 board_type; |
| 459 | 459 | ||
| 460 | u8 beacon_state; | ||
| 461 | |||
| 460 | struct qlcnic_nic_intr_coalesce coal; | 462 | struct qlcnic_nic_intr_coalesce coal; |
| 461 | struct qlcnic_fw_dump fw_dump; | 463 | struct qlcnic_fw_dump fw_dump; |
| 462 | }; | 464 | }; |
| @@ -931,6 +933,7 @@ struct qlcnic_ipaddr { | |||
| 931 | #define __QLCNIC_START_FW 4 | 933 | #define __QLCNIC_START_FW 4 |
| 932 | #define __QLCNIC_AER 5 | 934 | #define __QLCNIC_AER 5 |
| 933 | #define __QLCNIC_DIAG_RES_ALLOC 6 | 935 | #define __QLCNIC_DIAG_RES_ALLOC 6 |
| 936 | #define __QLCNIC_LED_ENABLE 7 | ||
| 934 | 937 | ||
| 935 | #define QLCNIC_INTERRUPT_TEST 1 | 938 | #define QLCNIC_INTERRUPT_TEST 1 |
| 936 | #define QLCNIC_LOOPBACK_TEST 2 | 939 | #define QLCNIC_LOOPBACK_TEST 2 |
| @@ -1397,6 +1400,9 @@ void qlcnic_pcie_sem_unlock(struct qlcnic_adapter *, int); | |||
| 1397 | #define crb_win_unlock(a) \ | 1400 | #define crb_win_unlock(a) \ |
| 1398 | qlcnic_pcie_sem_unlock((a), 7) | 1401 | qlcnic_pcie_sem_unlock((a), 7) |
| 1399 | 1402 | ||
| 1403 | #define __QLCNIC_MAX_LED_RATE 0xf | ||
| 1404 | #define __QLCNIC_MAX_LED_STATE 0x2 | ||
| 1405 | |||
| 1400 | int qlcnic_get_board_info(struct qlcnic_adapter *adapter); | 1406 | int qlcnic_get_board_info(struct qlcnic_adapter *adapter); |
| 1401 | int qlcnic_wol_supported(struct qlcnic_adapter *adapter); | 1407 | int qlcnic_wol_supported(struct qlcnic_adapter *adapter); |
| 1402 | int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate); | 1408 | int qlcnic_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c index 2230a62268aa..b127f809421b 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c | |||
| @@ -939,6 +939,9 @@ static int qlcnic_set_led(struct net_device *dev, | |||
| 939 | 939 | ||
| 940 | switch (state) { | 940 | switch (state) { |
| 941 | case ETHTOOL_ID_ACTIVE: | 941 | case ETHTOOL_ID_ACTIVE: |
| 942 | if (test_and_set_bit(__QLCNIC_LED_ENABLE, &adapter->state)) | ||
| 943 | return -EBUSY; | ||
| 944 | |||
| 942 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | 945 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { |
| 943 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | 946 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) |
| 944 | return -EIO; | 947 | return -EIO; |
| @@ -973,6 +976,8 @@ static int qlcnic_set_led(struct net_device *dev, | |||
| 973 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | 976 | clear_bit(__QLCNIC_RESETTING, &adapter->state); |
| 974 | } | 977 | } |
| 975 | 978 | ||
| 979 | clear_bit(__QLCNIC_LED_ENABLE, &adapter->state); | ||
| 980 | |||
| 976 | return -EIO; | 981 | return -EIO; |
| 977 | } | 982 | } |
| 978 | 983 | ||
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 998bb1d1a91f..690c93f76ae4 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
| @@ -3466,6 +3466,98 @@ int qlcnic_set_max_rss(struct qlcnic_adapter *adapter, u8 data) | |||
| 3466 | } | 3466 | } |
| 3467 | 3467 | ||
| 3468 | static int | 3468 | static int |
| 3469 | qlcnic_validate_beacon(struct qlcnic_adapter *adapter, u16 beacon, u8 *state, | ||
| 3470 | u8 *rate) | ||
| 3471 | { | ||
| 3472 | *rate = LSB(beacon); | ||
| 3473 | *state = MSB(beacon); | ||
| 3474 | |||
| 3475 | QLCDB(adapter, DRV, "rate %x state %x\n", *rate, *state); | ||
| 3476 | |||
| 3477 | if (!*state) { | ||
| 3478 | *rate = __QLCNIC_MAX_LED_RATE; | ||
| 3479 | return 0; | ||
| 3480 | } else if (*state > __QLCNIC_MAX_LED_STATE) | ||
| 3481 | return -EINVAL; | ||
| 3482 | |||
| 3483 | if ((!*rate) || (*rate > __QLCNIC_MAX_LED_RATE)) | ||
| 3484 | return -EINVAL; | ||
| 3485 | |||
| 3486 | return 0; | ||
| 3487 | } | ||
| 3488 | |||
| 3489 | static ssize_t | ||
| 3490 | qlcnic_store_beacon(struct device *dev, | ||
| 3491 | struct device_attribute *attr, const char *buf, size_t len) | ||
| 3492 | { | ||
| 3493 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
| 3494 | int max_sds_rings = adapter->max_sds_rings; | ||
| 3495 | int dev_down = 0; | ||
| 3496 | u16 beacon; | ||
| 3497 | u8 b_state, b_rate; | ||
| 3498 | int err; | ||
| 3499 | |||
| 3500 | if (len != sizeof(u16)) | ||
| 3501 | return QL_STATUS_INVALID_PARAM; | ||
| 3502 | |||
| 3503 | memcpy(&beacon, buf, sizeof(u16)); | ||
| 3504 | err = qlcnic_validate_beacon(adapter, beacon, &b_state, &b_rate); | ||
| 3505 | if (err) | ||
| 3506 | return err; | ||
| 3507 | |||
| 3508 | if (adapter->ahw->beacon_state == b_state) | ||
| 3509 | return len; | ||
| 3510 | |||
| 3511 | if (!adapter->ahw->beacon_state) | ||
| 3512 | if (test_and_set_bit(__QLCNIC_LED_ENABLE, &adapter->state)) | ||
| 3513 | return -EBUSY; | ||
| 3514 | |||
| 3515 | if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { | ||
| 3516 | if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) | ||
| 3517 | return -EIO; | ||
| 3518 | err = qlcnic_diag_alloc_res(adapter->netdev, QLCNIC_LED_TEST); | ||
| 3519 | if (err) { | ||
| 3520 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
| 3521 | clear_bit(__QLCNIC_LED_ENABLE, &adapter->state); | ||
| 3522 | return err; | ||
| 3523 | } | ||
| 3524 | dev_down = 1; | ||
| 3525 | } | ||
| 3526 | |||
| 3527 | err = qlcnic_config_led(adapter, b_state, b_rate); | ||
| 3528 | |||
| 3529 | if (!err) { | ||
| 3530 | adapter->ahw->beacon_state = b_state; | ||
| 3531 | err = len; | ||
| 3532 | } | ||
| 3533 | |||
| 3534 | if (dev_down) { | ||
| 3535 | qlcnic_diag_free_res(adapter->netdev, max_sds_rings); | ||
| 3536 | clear_bit(__QLCNIC_RESETTING, &adapter->state); | ||
| 3537 | } | ||
| 3538 | |||
| 3539 | if (!b_state) | ||
| 3540 | clear_bit(__QLCNIC_LED_ENABLE, &adapter->state); | ||
| 3541 | |||
| 3542 | return err; | ||
| 3543 | } | ||
| 3544 | |||
| 3545 | static ssize_t | ||
| 3546 | qlcnic_show_beacon(struct device *dev, | ||
| 3547 | struct device_attribute *attr, char *buf) | ||
| 3548 | { | ||
| 3549 | struct qlcnic_adapter *adapter = dev_get_drvdata(dev); | ||
| 3550 | |||
| 3551 | return sprintf(buf, "%d\n", adapter->ahw->beacon_state); | ||
| 3552 | } | ||
| 3553 | |||
| 3554 | static struct device_attribute dev_attr_beacon = { | ||
| 3555 | .attr = {.name = "beacon", .mode = (S_IRUGO | S_IWUSR)}, | ||
| 3556 | .show = qlcnic_show_beacon, | ||
| 3557 | .store = qlcnic_store_beacon, | ||
| 3558 | }; | ||
| 3559 | |||
| 3560 | static int | ||
| 3469 | qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, | 3561 | qlcnic_sysfs_validate_crb(struct qlcnic_adapter *adapter, |
| 3470 | loff_t offset, size_t size) | 3562 | loff_t offset, size_t size) |
| 3471 | { | 3563 | { |
| @@ -4162,6 +4254,8 @@ qlcnic_create_diag_entries(struct qlcnic_adapter *adapter) | |||
| 4162 | return; | 4254 | return; |
| 4163 | if (device_create_file(dev, &dev_attr_diag_mode)) | 4255 | if (device_create_file(dev, &dev_attr_diag_mode)) |
| 4164 | dev_info(dev, "failed to create diag_mode sysfs entry\n"); | 4256 | dev_info(dev, "failed to create diag_mode sysfs entry\n"); |
| 4257 | if (device_create_file(dev, &dev_attr_beacon)) | ||
| 4258 | dev_info(dev, "failed to create beacon sysfs entry"); | ||
| 4165 | if (device_create_bin_file(dev, &bin_attr_crb)) | 4259 | if (device_create_bin_file(dev, &bin_attr_crb)) |
| 4166 | dev_info(dev, "failed to create crb sysfs entry\n"); | 4260 | dev_info(dev, "failed to create crb sysfs entry\n"); |
| 4167 | if (device_create_bin_file(dev, &bin_attr_mem)) | 4261 | if (device_create_bin_file(dev, &bin_attr_mem)) |
| @@ -4192,6 +4286,7 @@ qlcnic_remove_diag_entries(struct qlcnic_adapter *adapter) | |||
| 4192 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) | 4286 | if (adapter->op_mode == QLCNIC_NON_PRIV_FUNC) |
| 4193 | return; | 4287 | return; |
| 4194 | device_remove_file(dev, &dev_attr_diag_mode); | 4288 | device_remove_file(dev, &dev_attr_diag_mode); |
| 4289 | device_remove_file(dev, &dev_attr_beacon); | ||
| 4195 | device_remove_bin_file(dev, &bin_attr_crb); | 4290 | device_remove_bin_file(dev, &bin_attr_crb); |
| 4196 | device_remove_bin_file(dev, &bin_attr_mem); | 4291 | device_remove_bin_file(dev, &bin_attr_mem); |
| 4197 | device_remove_bin_file(dev, &bin_attr_pci_config); | 4292 | device_remove_bin_file(dev, &bin_attr_pci_config); |
