From bc0e7c9b35e0290125847e322dce4609f83f2dc9 Mon Sep 17 00:00:00 2001 From: Dong Yibo Date: Fri, 29 Mar 2024 19:56:14 +0800 Subject: [PATCH] RNP: Fix warnings mucse inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9BK89 ---------------------------------------- LKP reports warnings when building for arm64 with "W=1 build" ...skipping... drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h:60:2: note: array 'priv' declared here 60 | char priv[0]; Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202403080243.ondrgrmr-lkp@intel.com/ Signed-off-by: Dong Yibo --- drivers/net/ethernet/mucse/rnp/rnp_common.h | 15 +- drivers/net/ethernet/mucse/rnp/rnp_dcb.h | 1 + drivers/net/ethernet/mucse/rnp/rnp_debugfs.c | 9 +- drivers/net/ethernet/mucse/rnp/rnp_ethtool.c | 259 ++++---- drivers/net/ethernet/mucse/rnp/rnp_ethtool.h | 13 +- drivers/net/ethernet/mucse/rnp/rnp_lib.c | 71 +-- drivers/net/ethernet/mucse/rnp/rnp_main.c | 583 ++++++++----------- drivers/net/ethernet/mucse/rnp/rnp_mbx.c | 22 +- drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.c | 213 +++---- drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h | 29 +- drivers/net/ethernet/mucse/rnp/rnp_n10.c | 572 +++++++++--------- drivers/net/ethernet/mucse/rnp/rnp_ptp.c | 51 +- drivers/net/ethernet/mucse/rnp/rnp_sriov.c | 138 ++--- drivers/net/ethernet/mucse/rnp/rnp_sysfs.c | 191 +++--- drivers/net/ethernet/mucse/rnp/rnp_type.h | 82 ++- drivers/net/ethernet/mucse/rnp/version.h | 2 +- 16 files changed, 1008 insertions(+), 1243 deletions(-) diff --git a/drivers/net/ethernet/mucse/rnp/rnp_common.h b/drivers/net/ethernet/mucse/rnp/rnp_common.h index b85bc6b87808..1ccbfa7c185f 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_common.h +++ b/drivers/net/ethernet/mucse/rnp/rnp_common.h @@ -139,7 +139,7 @@ static inline void hw_queue_strip_rx_vlan(struct rnp_hw *hw, u8 ring_num, u32 offset = ring_num % 32; u32 data = rd32(hw, reg); - if (enable == true) + if (enable) data |= (1 << offset); else data &= ~(1 << offset); @@ -151,7 +151,7 @@ static inline void hw_queue_strip_rx_vlan(struct rnp_hw *hw, u8 ring_num, u32 reg = reg_def; \ u32 value = rd32(hw, reg); \ dbg("before set %x %x\n", reg, value); \ - value |= (0x01 << bit); \ + value |= (0x01 << (bit)); \ dbg("after set %x %x\n", reg, value); \ wr32(hw, reg, value); \ } while (0) @@ -161,7 +161,7 @@ static inline void hw_queue_strip_rx_vlan(struct rnp_hw *hw, u8 ring_num, u32 reg = reg_def; \ u32 value = rd32(hw, reg); \ dbg("before clr %x %x\n", reg, value); \ - value &= (~(0x01 << bit)); \ + value &= (~(0x01 << (bit))); \ dbg("after clr %x %x\n", reg, value); \ wr32(hw, reg, value); \ } while (0) @@ -227,13 +227,13 @@ static inline void buf_dump_line(const char *msg, int line, void *buf, line, buf); for (i = 0; i < len; ++i) { - if ((i != 0) && (i % 16) == 0 && + if (i != 0 && (i % 16) == 0 && (offset >= (1024 - 10 * 16))) { printk(KERN_DEBUG "%s\n", msg_buf); offset = 0; } - if ((i != 0) && (i % 16) == 0) { + if (i != 0 && (i % 16) == 0) { offset += snprintf(msg_buf + offset, msg_len, "\n%03x: ", i); } @@ -265,13 +265,13 @@ static inline void buf_dump(const char *msg, void *buf, int len) "=== %s #%d ==\n000: ", msg, len); for (i = 0; i < len; ++i) { - if ((i != 0) && (i % 16) == 0 && + if (i != 0 && (i % 16) == 0 && (offset >= (1024 - 10 * 16))) { printk(KERN_DEBUG "%s\n", msg_buf); offset = 0; } - if ((i != 0) && (i % 16) == 0) { + if (i != 0 && (i % 16) == 0) { offset += snprintf(msg_buf + offset, msg_len, "\n%03x: ", i); } @@ -283,7 +283,6 @@ static inline void buf_dump(const char *msg, void *buf, int len) printk(KERN_DEBUG "%s\n", msg_buf); } - enum RNP_LOG_EVT { LOG_MBX_IN, LOG_MBX_OUT, diff --git a/drivers/net/ethernet/mucse/rnp/rnp_dcb.h b/drivers/net/ethernet/mucse/rnp/rnp_dcb.h index 90947243a122..e37d79996be7 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_dcb.h +++ b/drivers/net/ethernet/mucse/rnp/rnp_dcb.h @@ -12,6 +12,7 @@ enum rnp_pause_low_thrsh { RNP_PAUSE_144_SLOT_TIME, RNP_PAUSE_256_SLOT_TIME, }; + /*Rx Flow Ctrl */ #define RNP_RX_RFE BIT(0) /* Receive Flow Control Enable */ #define RNP_UP BIT(1) /* Unicast Pause Packet Detect */ diff --git a/drivers/net/ethernet/mucse/rnp/rnp_debugfs.c b/drivers/net/ethernet/mucse/rnp/rnp_debugfs.c index e45217193c9e..012076cd4755 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_debugfs.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_debugfs.c @@ -199,8 +199,8 @@ static ssize_t rnp_dbg_netdev_ops_write(struct file *filp, adapter->tx_timeout_count); } else if (strncmp(rnp_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) { - adapter->netdev->netdev_ops->ndo_tx_timeout( - adapter->netdev, UINT_MAX); + adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev, + UINT_MAX); e_dev_info("tx_timeout called\n"); } else { e_dev_info("Unknown command: %s\n", @@ -250,6 +250,7 @@ static ssize_t rnp_dbg_netdev_temp_read(struct file *filp, kfree(buf); return len; } + static const struct file_operations rnp_dbg_netdev_temp = { .owner = THIS_MODULE, .open = simple_open, @@ -294,7 +295,7 @@ void rnp_dbg_adapter_init(struct rnp_adapter *adapter) /** * rnp_dbg_adapter_exit - clear out the adapter's debugfs entries - * @pf: the pf that is stopping + * @adapter: the pf that is stopping **/ void rnp_dbg_adapter_exit(struct rnp_adapter *adapter) { @@ -308,7 +309,7 @@ void rnp_dbg_adapter_exit(struct rnp_adapter *adapter) void rnp_dbg_init(void) { rnp_dbg_root = debugfs_create_dir(rnp_driver_name, NULL); - if (rnp_dbg_root == NULL) + if (!rnp_dbg_root) pr_err("init of debugfs failed\n"); } diff --git a/drivers/net/ethernet/mucse/rnp/rnp_ethtool.c b/drivers/net/ethernet/mucse/rnp/rnp_ethtool.c index 77e030ca00dc..dc6e73dc816d 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_ethtool.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_ethtool.c @@ -36,7 +36,7 @@ int rnp_wol_exclusion(struct rnp_adapter *adapter, /* WOL not supported for all devices */ if (!rnp_wol_supported(adapter, hw->device_id, - hw->subsystem_device_id)) { + hw->subsystem_device_id)) { retval = 1; wol->supported = 0; } @@ -64,7 +64,6 @@ void rnp_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) wol->supported = hw->wol_supported; if (RNP_WOL_GET_STATUS(adapter)) wol->wolopts |= hw->wol_supported; - } /** @@ -89,8 +88,9 @@ int rnp_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) if (wol->wolopts & WAKE_MAGIC) { RNP_WOL_SET_SUPPORTED(adapter); RNP_WOL_SET_STATUS(adapter); - } else + } else { RNP_WOL_CLEAR_STATUS(adapter); + } rnp_mbx_wol_set(hw, RNP_WOL_GET_STATUS(adapter)); device_set_wakeup_enable(&adapter->pdev->dev, !!wol->wolopts); @@ -171,7 +171,7 @@ static bool reg_set_and_check(struct rnp_adapter *adapter, u64 *data, /** * rnp_reg_test - do register test * @adapter: board private structure - * @data test term + * @data: test term * * This function try to do register test **/ @@ -188,8 +188,7 @@ static bool rnp_reg_test(struct rnp_adapter *adapter, u64 *data) } test = reg_test_n10; - /* - * Perform the remainder of the register test, looping through + /* Perform the remainder of the register test, looping through * the test table until we either fail or reach the null entry. */ while (test->reg) { @@ -198,16 +197,16 @@ static bool rnp_reg_test(struct rnp_adapter *adapter, u64 *data) switch (test->test_type) { case PATTERN_TEST: - b = reg_pattern_test( - adapter, data, - test->reg + (i * 0x40), test->mask, - test->write); + b = reg_pattern_test(adapter, data, + test->reg + (i * 0x40), + test->mask, + test->write); break; case SET_READ_TEST: - b = reg_set_and_check( - adapter, data, - test->reg + (i * 0x40), test->mask, - test->write); + b = reg_set_and_check(adapter, data, + test->reg + (i * 0x40), + test->mask, + test->write); break; case WRITE_NO_TEST: wr32(hw, test->reg + (i * 0x40), @@ -215,21 +214,20 @@ static bool rnp_reg_test(struct rnp_adapter *adapter, u64 *data) break; case TABLE32_TEST: b = reg_pattern_test(adapter, data, - test->reg + (i * 4), - test->mask, - test->write); + test->reg + (i * 4), + test->mask, + test->write); break; case TABLE64_TEST_LO: b = reg_pattern_test(adapter, data, - test->reg + (i * 8), - test->mask, - test->write); + test->reg + (i * 8), + test->mask, + test->write); break; case TABLE64_TEST_HI: - b = reg_pattern_test( - adapter, data, - (test->reg + 4) + (i * 8), - test->mask, test->write); + b = reg_pattern_test(adapter, data, + (test->reg + 4) + (i * 8), + test->mask, test->write); break; } if (b) @@ -258,7 +256,7 @@ static int rnp_link_test(struct rnp_adapter *adapter, u64 *data) } void rnp_diag_test(struct net_device *netdev, - struct ethtool_test *eth_test, u64 *data) + struct ethtool_test *eth_test, u64 *data) { struct rnp_adapter *adapter = netdev_priv(netdev); struct rnp_hw *hw = &adapter->hw; @@ -272,7 +270,7 @@ void rnp_diag_test(struct net_device *netdev, for (i = 0; i < adapter->num_vfs; i++) { if (adapter->vfinfo[i].clear_to_send) { netdev_warn(netdev, "%s", - "offline diagnostic is not supported when VFs are present\n"); + "offline diagnostic is not supported when VFs are present\n"); data[0] = 1; data[1] = 1; data[2] = 1; @@ -280,7 +278,7 @@ void rnp_diag_test(struct net_device *netdev, eth_test->flags |= ETH_TEST_FL_FAILED; clear_bit(__RNP_TESTING, - &adapter->state); + &adapter->state); goto skip_ol_tests; } } @@ -310,8 +308,7 @@ void rnp_diag_test(struct net_device *netdev, */ if (adapter->flags & (RNP_FLAG_SRIOV_ENABLED | RNP_FLAG_VMDQ_ENABLED)) { - e_info(hw, - "Skip MAC loopback diagnostic in VT mode\n"); + e_info(hw, "Skip MAC loopback diagnostic in VT mode\n"); data[3] = 0; goto skip_loopback; } @@ -457,7 +454,7 @@ int rnp_set_phys_id(struct net_device *netdev, /** * rnp_get_ts_info - get the time stamping and PTP hardware clock capabilities - * @netdev: network interface device structure + * @dev: network interface device structure * @info: info structure * * This function is called when ethtool -T:. @@ -518,7 +515,7 @@ static unsigned int rnp_max_channels(struct rnp_adapter *adapter) /** * rnp_get_channels - set ring num - * @netdev: network interface device structure + * @dev: network interface device structure * @ch: channel structure * * This function is called when ethtool -l. @@ -552,7 +549,7 @@ void rnp_get_channels(struct net_device *dev, struct ethtool_channels *ch) /** * rnp_set_channels - set ring num - * @netdev: network interface device structure + * @dev: network interface device structure * @ch: channel structure * * This function is called when ethtool -L. @@ -590,7 +587,7 @@ int rnp_set_channels(struct net_device *dev, struct ethtool_channels *ch) /** * rnp_get_module_info - get size and type of eeprom within a plug-in module - * @netdev: network interface device structure + * @dev: network interface device structure * @modinfo: modinfo structure * * This function is called when ethtool -m. @@ -611,8 +608,9 @@ int rnp_get_module_info(struct net_device *dev, 1, &module_id); if (rc || module_id == 0xff) return -EIO; - rc = rnp_mbx_sfp_module_eeprom_info( - hw, 0xA0, SFF_DIAG_SUPPORT_OFFSET, 1, &diag_supported); + rc = rnp_mbx_sfp_module_eeprom_info(hw, 0xA0, + SFF_DIAG_SUPPORT_OFFSET, 1, + &diag_supported); if (!rc) { switch (module_id) { case SFF_MODULE_ID_SFP: @@ -642,7 +640,7 @@ int rnp_get_module_info(struct net_device *dev, /** * rnp_get_module_eeprom - get module eeprom info - * @netdev: network interface device structure + * @dev: network interface device structure * @eeprom: eeprom structure * @data: data buffer * @@ -690,6 +688,8 @@ int rnp_get_module_eeprom(struct net_device *dev, * rnp_get_ringparam - get ring desc num * @netdev: network interface device structure * @ring: ring structure + * @ker: ker info + * @extack: extack info * * This function is called when ethtool -g. **/ @@ -715,6 +715,8 @@ void rnp_get_ringparam(struct net_device *netdev, * rnp_set_ringparam - set ring desc num * @netdev: network interface device structure * @ring: ring structure + * @ker: ker info + * @extack: extack info * * This function is called when ethtool -G. **/ @@ -732,18 +734,17 @@ int rnp_set_ringparam(struct net_device *netdev, if (adapter->flags & RNP_FLAG_SRIOV_ENABLED) return -EINVAL; - if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) + if (ring->rx_mini_pending || ring->rx_jumbo_pending) return -EINVAL; - if ((ring->tx_pending < RNP_MIN_TXD) || - (ring->tx_pending > RNP_MAX_TXD) || - (ring->rx_pending < RNP_MIN_RXD) || - (ring->rx_pending > RNP_MAX_RXD)) { - netdev_info( - netdev, - "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", - ring->tx_pending, ring->rx_pending, RNP_MIN_TXD, - RNP_MAX_TXD); + if (ring->tx_pending < RNP_MIN_TXD || + ring->tx_pending > RNP_MAX_TXD || + ring->rx_pending < RNP_MIN_RXD || + ring->rx_pending > RNP_MAX_RXD) { + netdev_info(netdev, + "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", + ring->tx_pending, ring->rx_pending, RNP_MIN_TXD, + RNP_MAX_TXD); return -EINVAL; } @@ -755,8 +756,8 @@ int rnp_set_ringparam(struct net_device *netdev, clamp_t(u32, ring->rx_pending, RNP_MIN_RXD, RNP_MAX_RXD); new_rx_count = ALIGN(new_rx_count, RNP_REQ_RX_DESCRIPTOR_MULTIPLE); - if ((new_tx_count == adapter->tx_ring_item_count) && - (new_rx_count == adapter->rx_ring_item_count)) + if (new_tx_count == adapter->tx_ring_item_count && + new_rx_count == adapter->rx_ring_item_count) return 0; while (test_and_set_bit(__RNP_RESETTING, &adapter->state)) @@ -791,8 +792,7 @@ int rnp_set_ringparam(struct net_device *netdev, } rnp_down(adapter); - /* - * Setup new Tx resources and free the old Tx resources in that order. + /* Setup new Tx resources and free the old Tx resources in that order. * We can then assign the new resources to the rings via a memcpy. * The advantage to this approach is that we are guaranteed to still * have resources even in the case of an allocation failure. @@ -808,8 +808,7 @@ int rnp_set_ringparam(struct net_device *netdev, if (err) { while (i) { i--; - rnp_free_tx_resources( - &temp_ring[i]); + rnp_free_tx_resources(&temp_ring[i]); } goto err_setup; } @@ -845,8 +844,7 @@ int rnp_set_ringparam(struct net_device *netdev, if (err) { while (i) { i--; - rnp_free_rx_resources( - &temp_ring[i]); + rnp_free_rx_resources(&temp_ring[i]); } goto err_setup; } @@ -891,7 +889,7 @@ int rnp_get_dump_flag(struct net_device *netdev, struct ethtool_dump *dump) /** * rnp_get_dump_data - get dump data * @netdev: network interface device structure - * @dump: dump sturcture + * @dump: dump struct * @buffer: buffer for data * * This function is called when ethtool -w. @@ -933,8 +931,9 @@ int rnp_set_dump(struct net_device *netdev, struct ethtool_dump *dump) /** * rnp_get_coalesce - get coalesce info from hw * @netdev: network interface device structure - * @cmd: value from ethtool - * @ec: coalesce info + * @coal: value from ethtool + * @kernel_coal: kernel_coal + * @extack: extack * * This function is called when ethtool -c. **/ @@ -975,8 +974,9 @@ int rnp_get_coalesce(struct net_device *netdev, /** * rnp_set_coalesce - setup coalesce info to hw * @netdev: network interface device structure - * @cmd: value from ethtool * @ec: coalesce info + * @kernel_coal: kernel_coal + * @extack: extack * * This function is called when ethtool -C. **/ @@ -994,8 +994,8 @@ int rnp_set_coalesce(struct net_device *netdev, !(ec->use_adaptive_rx_coalesce)) return -EINVAL; - if ((ec->tx_max_coalesced_frames_irq < RNP_MIN_TX_WORK) || - (ec->tx_max_coalesced_frames_irq > RNP_MAX_TX_WORK)) + if (ec->tx_max_coalesced_frames_irq < RNP_MIN_TX_WORK || + ec->tx_max_coalesced_frames_irq > RNP_MAX_TX_WORK) return -EINVAL; value = clamp_t(u32, ec->tx_max_coalesced_frames_irq, @@ -1007,8 +1007,8 @@ int rnp_set_coalesce(struct net_device *netdev, adapter->tx_work_limit = value; } - if ((ec->tx_max_coalesced_frames < RNP_MIN_TX_FRAME) || - (ec->tx_max_coalesced_frames > RNP_MAX_TX_FRAME)) + if (ec->tx_max_coalesced_frames < RNP_MIN_TX_FRAME || + ec->tx_max_coalesced_frames > RNP_MAX_TX_FRAME) return -EINVAL; value = clamp_t(u32, ec->tx_max_coalesced_frames, @@ -1017,8 +1017,8 @@ int rnp_set_coalesce(struct net_device *netdev, reset = 1; adapter->tx_frames = value; } - if ((ec->tx_coalesce_usecs < RNP_MIN_TX_USEC) || - (ec->tx_coalesce_usecs > RNP_MAX_TX_USEC)) + if (ec->tx_coalesce_usecs < RNP_MIN_TX_USEC || + ec->tx_coalesce_usecs > RNP_MAX_TX_USEC) return -EINVAL; value = clamp_t(u32, ec->tx_coalesce_usecs, @@ -1028,8 +1028,8 @@ int rnp_set_coalesce(struct net_device *netdev, adapter->tx_usecs = value; } - if ((ec->rx_max_coalesced_frames_irq < RNP_MIN_RX_WORK) || - (ec->rx_max_coalesced_frames_irq > RNP_MAX_RX_WORK)) + if (ec->rx_max_coalesced_frames_irq < RNP_MIN_RX_WORK || + ec->rx_max_coalesced_frames_irq > RNP_MAX_RX_WORK) return -EINVAL; value = clamp_t(u32, ec->rx_max_coalesced_frames_irq, RNP_MIN_RX_WORK, RNP_MAX_RX_WORK); @@ -1040,8 +1040,8 @@ int rnp_set_coalesce(struct net_device *netdev, adapter->napi_budge = value; } - if ((ec->rx_max_coalesced_frames < RNP_MIN_RX_FRAME) || - (ec->rx_max_coalesced_frames > RNP_MAX_RX_FRAME)) + if (ec->rx_max_coalesced_frames < RNP_MIN_RX_FRAME || + ec->rx_max_coalesced_frames > RNP_MAX_RX_FRAME) return -EINVAL; value = clamp_t(u32, ec->rx_max_coalesced_frames, @@ -1051,8 +1051,8 @@ int rnp_set_coalesce(struct net_device *netdev, adapter->rx_frames = value; } - if ((ec->rx_coalesce_usecs < RNP_MIN_RX_USEC) || - (ec->rx_coalesce_usecs > RNP_MAX_RX_USEC)) + if (ec->rx_coalesce_usecs < RNP_MIN_RX_USEC || + ec->rx_coalesce_usecs > RNP_MAX_RX_USEC) return -EINVAL; value = clamp_t(u32, ec->rx_coalesce_usecs, RNP_MIN_RX_USEC, RNP_MAX_RX_USEC); @@ -1062,17 +1062,18 @@ int rnp_set_coalesce(struct net_device *netdev, } /* other setup is not supported */ - if ((ec->pkt_rate_low) || (ec->pkt_rate_high) || - (ec->rx_coalesce_usecs_low) || - (ec->rx_max_coalesced_frames_low) || - (ec->tx_coalesce_usecs_low) || - (ec->tx_max_coalesced_frames_low) || - (ec->rx_coalesce_usecs_high) || - (ec->rx_max_coalesced_frames_high) || - (ec->tx_coalesce_usecs_high) || - (ec->tx_max_coalesced_frames_high) || - (ec->rate_sample_interval) || (ec->tx_coalesce_usecs_irq) || - (ec->rx_coalesce_usecs_irq)) + if (ec->pkt_rate_low || ec->pkt_rate_high || + ec->rx_coalesce_usecs_low || + ec->rx_max_coalesced_frames_low || + ec->tx_coalesce_usecs_low || + ec->tx_max_coalesced_frames_low || + ec->rx_coalesce_usecs_high || + ec->rx_max_coalesced_frames_high || + ec->tx_coalesce_usecs_high || + ec->tx_max_coalesced_frames_high || + ec->rate_sample_interval || + ec->tx_coalesce_usecs_irq || + ec->rx_coalesce_usecs_irq) return -EINVAL; if (reset) @@ -1081,8 +1082,6 @@ int rnp_set_coalesce(struct net_device *netdev, return 0; } - - static int rnp_get_rss_hash_opts(struct rnp_adapter *adapter, struct ethtool_rxnfc *cmd) { @@ -1122,7 +1121,6 @@ static int rnp_get_rss_hash_opts(struct rnp_adapter *adapter, return 0; } - static int rnp_get_ethtool_fdir_entry(struct rnp_adapter *adapter, struct ethtool_rxnfc *cmd) { @@ -1220,9 +1218,9 @@ static int rnp_get_ethtool_fdir_entry(struct rnp_adapter *adapter, } /* record action */ - if (rule->action == RNP_FDIR_DROP_QUEUE) + if (rule->action == RNP_FDIR_DROP_QUEUE) { fsp->ring_cookie = RX_CLS_FLOW_DISC; - else { + } else { int add = 0; if (rule->action & 0x1) @@ -1310,8 +1308,7 @@ int rnp_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, static int rnp_set_rss_hash_opt(struct rnp_adapter *adapter, struct ethtool_rxnfc *nfc) { - /* - * RSS does not support anything other than hashing + /* RSS does not support anything other than hashing * to queues on src and dst IPs and ports */ if (nfc->data & @@ -1351,7 +1348,7 @@ static int rnp_set_rss_hash_opt(struct rnp_adapter *adapter, static int rnp_flowspec_to_flow_type(struct rnp_adapter *adapter, struct ethtool_rx_flow_spec *fsp, - uint8_t *flow_type, + u8 *flow_type, struct rnp_fdir_filter *input) { int i; @@ -1436,18 +1433,18 @@ static int rnp_flowspec_to_flow_type(struct rnp_adapter *adapter, e_err(drv, "tuple 5 count full\n"); ret = 0; } - if ((fsp->h_u.usr_ip4_spec.ip4src != 0) && - (fsp->m_u.usr_ip4_spec.ip4src != 0xffffffff)) { + if (fsp->h_u.usr_ip4_spec.ip4src != 0 && + fsp->m_u.usr_ip4_spec.ip4src != 0xffffffff) { e_err(drv, "ip src mask error\n"); ret = 0; } - if ((fsp->h_u.usr_ip4_spec.ip4dst != 0) && - (fsp->m_u.usr_ip4_spec.ip4dst != 0xffffffff)) { + if (fsp->h_u.usr_ip4_spec.ip4dst != 0 && + fsp->m_u.usr_ip4_spec.ip4dst != 0xffffffff) { e_err(drv, "ip dst mask error\n"); ret = 0; } - if ((fsp->h_u.usr_ip4_spec.proto != 0) && - (fsp->m_u.usr_ip4_spec.proto != 0xff)) { + if (fsp->h_u.usr_ip4_spec.proto != 0 && + fsp->m_u.usr_ip4_spec.proto != 0xff) { e_err(drv, "ip l4 proto mask error\n"); ret = 0; } @@ -1458,7 +1455,7 @@ static int rnp_flowspec_to_flow_type(struct rnp_adapter *adapter, } } /* not support l4_4_bytes */ - if ((fsp->h_u.usr_ip4_spec.l4_4_bytes != 0)) { + if (fsp->h_u.usr_ip4_spec.l4_4_bytes != 0) { e_err(drv, "ip l4_4_bytes error\n"); ret = 0; } @@ -1469,23 +1466,23 @@ static int rnp_flowspec_to_flow_type(struct rnp_adapter *adapter, e_err(drv, "tuple 5 count full\n"); ret = 0; } - if ((fsp->h_u.tcp_ip4_spec.ip4src != 0) && - (fsp->m_u.tcp_ip4_spec.ip4src != 0xffffffff)) { + if (fsp->h_u.tcp_ip4_spec.ip4src != 0 && + fsp->m_u.tcp_ip4_spec.ip4src != 0xffffffff) { e_err(drv, "src mask error\n"); ret = 0; } - if ((fsp->h_u.tcp_ip4_spec.ip4dst != 0) && - (fsp->m_u.tcp_ip4_spec.ip4dst != 0xffffffff)) { + if (fsp->h_u.tcp_ip4_spec.ip4dst != 0 && + fsp->m_u.tcp_ip4_spec.ip4dst != 0xffffffff) { e_err(drv, "dst mask error\n"); ret = 0; } - if ((fsp->h_u.tcp_ip4_spec.psrc != 0) && - (fsp->m_u.tcp_ip4_spec.psrc != 0xffff)) { + if (fsp->h_u.tcp_ip4_spec.psrc != 0 && + fsp->m_u.tcp_ip4_spec.psrc != 0xffff) { e_err(drv, "src port mask error\n"); ret = 0; } - if ((fsp->h_u.tcp_ip4_spec.pdst != 0) && - (fsp->m_u.tcp_ip4_spec.pdst != 0xffff)) { + if (fsp->h_u.tcp_ip4_spec.pdst != 0 && + fsp->m_u.tcp_ip4_spec.pdst != 0xffff) { e_err(drv, "src port mask error\n"); ret = 0; } @@ -1505,7 +1502,6 @@ static int rnp_flowspec_to_flow_type(struct rnp_adapter *adapter, return ret; } - /** * rnp_update_ethtool_fdir_entry- update a fidr entry to hw * @adapter: board private structure @@ -1542,10 +1538,10 @@ int rnp_update_ethtool_fdir_entry(struct rnp_adapter *adapter, * and we should not issue filter commands while the interface * is down */ - if (netif_running(adapter->netdev) && (!input)) { - err = rnp_fdir_erase_perfect_filter( - adapter->fdir_mode, hw, &rule->filter, - rule->hw_idx); + if (netif_running(adapter->netdev) && !input) { + err = rnp_fdir_erase_perfect_filter(adapter->fdir_mode, + hw, &rule->filter, + rule->hw_idx); if (err) return -EINVAL; } @@ -1596,7 +1592,7 @@ int rnp_update_ethtool_fdir_entry(struct rnp_adapter *adapter, else rule->hw_idx = hw_idx_tuple5++; - if ((!rule->vf_num) && (rule->action != ACTION_TO_MPE)) { + if (!rule->vf_num && (rule->action != ACTION_TO_MPE)) { int idx = rule->action; err = rnp_fdir_write_perfect_filter( @@ -1635,7 +1631,7 @@ int rnp_update_ethtool_fdir_entry(struct rnp_adapter *adapter, } static int rnp_add_ethtool_fdir_entry(struct rnp_adapter *adapter, - struct ethtool_rxnfc *cmd) + struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; @@ -1643,8 +1639,6 @@ static int rnp_add_ethtool_fdir_entry(struct rnp_adapter *adapter, struct rnp_hw *hw = &adapter->hw; int err; int vf_fix = 0; - - u32 ring_cookie_high = fsp->ring_cookie >> 32; if (hw->feature_flags & RNP_NET_FEATURE_VF_FIXED) @@ -1653,29 +1647,28 @@ static int rnp_add_ethtool_fdir_entry(struct rnp_adapter *adapter, if (!(adapter->flags & RNP_FLAG_FDIR_PERFECT_CAPABLE)) return -EOPNOTSUPP; - /* - * Don't allow programming if the action is a queue greater than + /* Don't allow programming if the action is a queue greater than * the number of online Rx queues. */ /* is sriov is on, allow vf and queue */ /* vf should smaller than num_vfs */ if (adapter->flags & RNP_FLAG_SRIOV_ENABLED) { - if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) && + if (fsp->ring_cookie != RX_CLS_FLOW_DISC && (((ring_cookie_high & 0xff) > adapter->num_vfs) || ((fsp->ring_cookie & (u64)0xffffffff) >= hw->sriov_ring_limit))) return -EINVAL; } else { - if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) && - (fsp->ring_cookie >= adapter->num_rx_queues)) { + if (fsp->ring_cookie != RX_CLS_FLOW_DISC && + fsp->ring_cookie >= adapter->num_rx_queues) { if (fsp->ring_cookie != ACTION_TO_MPE) return -EINVAL; } } /* Don't allow indexes to exist outside of available space */ - if (fsp->location >= (adapter->fdir_pballoc)) { + if (fsp->location >= adapter->fdir_pballoc) { e_err(drv, "Location out of range\n"); return -EINVAL; } @@ -1689,8 +1682,8 @@ static int rnp_add_ethtool_fdir_entry(struct rnp_adapter *adapter, /* record flow type */ if (!rnp_flowspec_to_flow_type(adapter, fsp, - &input->filter.formatted.flow_type, - input)) { + &input->filter.formatted.flow_type, + input)) { e_err(drv, "Unrecognized flow type\n"); goto err_out; } @@ -1737,20 +1730,21 @@ static int rnp_add_ethtool_fdir_entry(struct rnp_adapter *adapter, } /* determine if we need to drop or route the packet */ - if (fsp->ring_cookie == RX_CLS_FLOW_DISC) + if (fsp->ring_cookie == RX_CLS_FLOW_DISC) { input->action = RNP_FDIR_DROP_QUEUE; - else { + } else { input->vf_num = (fsp->ring_cookie >> 32) & 0xff; if (input->vf_num) { /* in vf mode input->action is the real queue nums */ - if (adapter->priv_flags & RNP_PRIV_FLAG_REMAP_MODE) + if (adapter->priv_flags & RNP_PRIV_FLAG_REMAP_MODE) { input->action = (fsp->ring_cookie & 0xffffffff); - else { + } else { input->action = 2 * (input->vf_num + vf_fix - 1) + (fsp->ring_cookie & 0xffffffff); } - } else + } else { input->action = fsp->ring_cookie; + } } spin_lock(&adapter->fdir_perfect_lock); @@ -1778,8 +1772,8 @@ static int rnp_del_ethtool_fdir_entry(struct rnp_adapter *adapter, } /** - * rnp_set_rxfh - add / del fdir entry or set hash function - * @netdev: network interface device structure + * rnp_set_rxnfc - add / del fdir entry or set hash function + * @dev: network interface device structure * @cmd: value from ethtool * * This function is called when ethtool -N. @@ -1844,7 +1838,7 @@ static void rnp_get_reta(struct rnp_adapter *adapter, u32 *indir) } /** - * rnp_tet_rxfh - get indir, key or hfunc info + * rnp_get_rxfh - get indir, key or hfunc info * @netdev: network interface device structure * @indir: rss table value * @key: rss key value @@ -1880,7 +1874,6 @@ int rnp_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, u8 *hfunc) return 0; } - static int rnp_rss_indir_tbl_max(struct rnp_adapter *adapter) { if (adapter->hw.rss_type == rnp_rss_uv3p) @@ -1931,7 +1924,7 @@ int rnp_set_rxfh(struct net_device *netdev, const u32 *indir, rnp_rss_indir_tbl_max(adapter)); if ((adapter->flags & RNP_FLAG_SRIOV_ENABLED) && - (max_queues > hw->sriov_ring_limit)) + max_queues > hw->sriov_ring_limit) max_queues = hw->sriov_ring_limit; /* Verify user input. */ @@ -1992,7 +1985,7 @@ static int rnp_flash_firmware(struct rnp_adapter *adapter, int region, return err; /* skip ucfg flush only pxe */ err = rnp_fw_update(hw, PART_PXE, data + PXE_OFF, - wbytes_seg1); + wbytes_seg1); if (err) return err; return 0; @@ -2050,7 +2043,7 @@ int rnp_flash_device(struct net_device *netdev, struct ethtool_flash *flash) if (IS_VF(adapter->hw.pfvfnum)) { netdev_err(netdev, - "flashdev not supported from a virtual function\n"); + "flashdev not supported from a virtual function\n"); return -EINVAL; } diff --git a/drivers/net/ethernet/mucse/rnp/rnp_ethtool.h b/drivers/net/ethernet/mucse/rnp/rnp_ethtool.h index 9c9fa78f357d..823745d0e860 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_ethtool.h +++ b/drivers/net/ethernet/mucse/rnp/rnp_ethtool.h @@ -4,12 +4,11 @@ #ifndef _RNP_ETHTOOL_H_ #define _RNP_ETHTOOL_H_ - -#define RNP_WOL_GET_SUPPORTED(adapter) (!!(adapter->wol & GENMASK(3, 0))) -#define RNP_WOL_GET_STATUS(adapter) (!!(adapter->wol & GENMASK(7, 4))) -#define RNP_WOL_SET_SUPPORTED(adapter) (adapter->wol |= BIT(0)) -#define RNP_WOL_SET_STATUS(adapter) (adapter->wol |= BIT(4)) -#define RNP_WOL_CLEAR_STATUS(adapter) (adapter->wol &= ~BIT(4)) +#define RNP_WOL_GET_SUPPORTED(adapter) (!!((adapter)->wol & GENMASK(3, 0))) +#define RNP_WOL_GET_STATUS(adapter) (!!((adapter)->wol & GENMASK(7, 4))) +#define RNP_WOL_SET_SUPPORTED(adapter) ((adapter)->wol |= BIT(0)) +#define RNP_WOL_SET_STATUS(adapter) ((adapter)->wol |= BIT(4)) +#define RNP_WOL_CLEAR_STATUS(adapter) ((adapter)->wol &= ~BIT(4)) /* rnp allocates num_tx_queues and num_rx_queues symmetrically so * we set the num_rx_queues to evaluate to num_tx_queues. This is @@ -65,7 +64,7 @@ struct rnp_rx_queue_ring_stat { RNP_NUM_RX_QUEUES * \ (sizeof(struct rnp_rx_queue_stats) / sizeof(u64) + \ sizeof(struct rnp_queue_stats) / sizeof(u64) + \ - sizeof(struct rnp_rx_queue_ring_stat) / sizeof(u64))) + sizeof(struct rnp_rx_queue_ring_stat) / sizeof(u64) - 2)) #define RNP_STATS_LEN \ (RNP_GLOBAL_STATS_LEN + RNP_HWSTRINGS_STATS_LEN + \ diff --git a/drivers/net/ethernet/mucse/rnp/rnp_lib.c b/drivers/net/ethernet/mucse/rnp/rnp_lib.c index 8f2b5a6d7339..771b8ea6cfe7 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_lib.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_lib.c @@ -56,8 +56,7 @@ static bool rnp_cache_ring_dcb(struct rnp_adapter *adapter) step = 4; for (tc = 0, offset = 0; tc < num_tcs; tc++, offset += rss_i) { - /* - * we from tc start + /* we from tc start * tc0 0 4 8 c * tc1 1 5 9 d * tc2 2 6 a e @@ -242,8 +241,7 @@ static bool rnp_set_dcb_sriov_queues(struct rnp_adapter *adapter) adapter->ring_feature[RING_F_VMDQ].indices = vmdq_i; adapter->ring_feature[RING_F_VMDQ].mask = vmdq_m; - /* - * We do not support DCB, VMDq, and RSS all simultaneously + /* We do not support DCB, VMDq, and RSS all simultaneously * so we will disable RSS since it is the lowest priority */ adapter->ring_feature[RING_F_RSS].indices = 2; @@ -412,8 +410,7 @@ static bool rnp_set_rss_queues(struct rnp_adapter *adapter) * This is the top level queue allocation routine. The order here is very * important, starting with the "most" number of features turned on at once, * and ending with the smallest set of features. This way large combinations - * can be allocated if they're turned on, and smaller combinations are the - * fallthrough conditions. + * can be allocated if they're turned on. * **/ static void rnp_set_num_queues(struct rnp_adapter *adapter) @@ -436,7 +433,7 @@ static void rnp_set_num_queues(struct rnp_adapter *adapter) rnp_set_rss_queues(adapter); } -int rnp_acquire_msix_vectors(struct rnp_adapter *adapter, int vectors) +static int rnp_acquire_msix_vectors(struct rnp_adapter *adapter, int vectors) { int err; #define MIN_VECTORS (2) @@ -449,10 +446,9 @@ int rnp_acquire_msix_vectors(struct rnp_adapter *adapter, int vectors) adapter->msix_entries = NULL; return -EINVAL; } - /* use ture msix count */ + /* use true msix count */ vectors = err; - /* - * Adjust for only the vectors we'll use, which is minimum + /* Adjust for only the vectors we'll use, which is minimum * of max_msix_q_vectors + NON_Q_VECTORS, or the number of * vectors we were allocated. */ @@ -529,7 +525,7 @@ static enum hrtimer_restart irq_miss_check(struct hrtimer *hrtimer) if ((eop_desc->vlan_cmd & cpu_to_le32(RNP_TXD_STAT_DD))) { if (q_vector->new_rx_count != q_vector->old_rx_count) { ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_PKTCNT, - q_vector->new_rx_count); + q_vector->new_rx_count); q_vector->old_rx_count = q_vector->new_rx_count; } napi_schedule_irqoff(&q_vector->napi); @@ -548,7 +544,7 @@ static enum hrtimer_restart irq_miss_check(struct hrtimer *hrtimer) if (size) { if (q_vector->new_rx_count != q_vector->old_rx_count) { ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_PKTCNT, - q_vector->new_rx_count); + q_vector->new_rx_count); q_vector->old_rx_count = q_vector->new_rx_count; } napi_schedule_irqoff(&q_vector->napi); @@ -569,12 +565,11 @@ static enum hrtimer_restart irq_miss_check(struct hrtimer *hrtimer) /** * rnp_alloc_q_vector - Allocate memory for a single interrupt vector * @adapter: board private structure to initialize - * @v_count: q_vectors allocated on adapter, used for ring interleaving + * @eth_queue_idx: q_vectors allocated on adapter, used for ring interleaving * @v_idx: index of vector in adapter struct - * @txr_count: total number of Tx rings to allocate - * @txr_idx: index of first Tx ring to allocate - * @rxr_count: total number of Rx rings to allocate - * @rxr_idx: index of first Rx ring to allocate + * @r_idx: ring idx + * @r_count: total number of rings to allocate + * @step: ring steps * * We allocate one q_vector. If allocation fails we return -ENOMEM. **/ @@ -593,13 +588,8 @@ static int rnp_alloc_q_vector(struct rnp_adapter *adapter, int rxr_idx = r_idx, txr_idx = r_idx; int cpu_offset = 0; - DPRINTK(PROBE, INFO, - "eth_queue_idx:%d v_idx:%d(off:%d) ring:%d ring_cnt:%d,", - eth_queue_idx, v_idx, adapter->q_vector_off, r_idx, - r_count); - DPRINTK(PROBE, INFO, "step:%d\n", step); - - txr_count = rxr_count = r_count; + rxr_count = r_count; + txr_count = rxr_count; ring_count = txr_count + rxr_count; size = sizeof(struct rnp_q_vector) + @@ -730,7 +720,7 @@ static int rnp_alloc_q_vector(struct rnp_adapter *adapter, /* push pointer to next ring */ ring++; } - if ((hw->hw_type == rnp_hw_n10) || (hw->hw_type == rnp_hw_n400)) { + if (hw->hw_type == rnp_hw_n10 || hw->hw_type == rnp_hw_n400) { q_vector->vector_flags |= RNP_QVECTOR_FLAG_IRQ_MISS_CHECK; /* initialize timer */ q_vector->irq_check_usecs = 1000; @@ -773,8 +763,7 @@ static void rnp_free_q_vector(struct rnp_adapter *adapter, int v_idx) if (q_vector->vector_flags & RNP_QVECTOR_FLAG_IRQ_MISS_CHECK) hrtimer_cancel(&q_vector->irq_miss_check_timer); - /* - * rnp_get_stats64() might access the rings on this vector, + /* rnp_get_stats64() might access the rings on this vector, * we must wait a grace period before freeing it. */ kfree_rcu(q_vector, rcu); @@ -833,8 +822,8 @@ static int rnp_alloc_q_vectors(struct rnp_adapter *adapter) BUG_ON(ring_cnt != adapter->num_tc); err = rnp_alloc_q_vector(adapter, adapter->eth_queue_idx, - v_idx, ring_idx, ring_cnt, - ring_step); + v_idx, ring_idx, ring_cnt, + ring_step); if (err) goto err_out; ring_idx += ring_step * ring_cnt; @@ -925,8 +914,9 @@ static int rnp_set_interrupt_capability(struct rnp_adapter *adapter) v_budget = min_t(int, v_budget, hw->mac.max_msix_vectors); if (adapter->irq_mode == irq_mode_msix) { - adapter->msix_entries = kcalloc( - v_budget, sizeof(struct msix_entry), GFP_KERNEL); + adapter->msix_entries = kcalloc(v_budget, + sizeof(struct msix_entry), + GFP_KERNEL); if (!adapter->msix_entries) { rnp_err("alloc msix_entries failed!\n"); @@ -974,14 +964,12 @@ static int rnp_set_interrupt_capability(struct rnp_adapter *adapter) adapter->irq_mode = irq_mode_back; /* legacy and msi only 1 vectors */ adapter->num_q_vectors = 1; - //if (adapter->num_other_vectors) // vector0 reversed for mbx - // adapter->q_vector_off = 1; out: return err; } -void rnp_print_ring_info(struct rnp_adapter *adapter) +static void rnp_print_ring_info(struct rnp_adapter *adapter) { int i; struct rnp_ring *ring; @@ -1045,7 +1033,6 @@ int rnp_init_interrupt_scheme(struct rnp_adapter *adapter) } rnp_cache_ring_register(adapter); - // printk now qvctor ring setup DPRINTK(PROBE, INFO, "Multiqueue %s: Rx Queue count = %u, Tx Queue count = %u\n\n", (adapter->num_rx_queues > 1) ? "Enabled" : "Disabled", @@ -1081,11 +1068,10 @@ void rnp_clear_interrupt_scheme(struct rnp_adapter *adapter) /** * rnp_tx_ctxtdesc - Send a control desc to hw * @tx_ring: target ring of this control desc - * @mss_seg_len: mss length - * @l4_hdr_len: l4 length - * @tunnel_hdr_len: tunnel_hdr_len - * @inner_vlan_tag: inner_vlan_tag - * @type_tucmd: cmd + * @mss_len_vf_num: mss_len_vf_num + * @inner_vlan_tunnel_len: inner_vlan_tunnel_len + * @ignore_vlan: ignore_vlan flag + * @crc_pad: crc_pad flag * **/ @@ -1138,6 +1124,7 @@ void rnp_tx_ctxtdesc(struct rnp_ring *tx_ring, u32 mss_len_vf_num, buf_dump_line("ctx ", __LINE__, context_desc, sizeof(*context_desc)); } + void rnp_maybe_tx_ctxtdesc(struct rnp_ring *tx_ring, struct rnp_tx_buffer *first, u32 ignore_vlan) { @@ -1159,9 +1146,9 @@ void rnp_store_reta(struct rnp_adapter *adapter) /* Write redirection table to HW */ for (i = 0; i < reta_entries; i++) { - if (adapter->flags & RNP_FLAG_SRIOV_ENABLED) + if (adapter->flags & RNP_FLAG_SRIOV_ENABLED) { reta = adapter->rss_indir_tbl[i]; - else { + } else { rx_ring = adapter->rx_ring[adapter->rss_indir_tbl[i]]; reta = rx_ring->rnp_queue_idx; diff --git a/drivers/net/ethernet/mucse/rnp/rnp_main.c b/drivers/net/ethernet/mucse/rnp/rnp_main.c index 1e1a5cade9ff..a9bf2b0c17fc 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_main.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_main.c @@ -52,7 +52,6 @@ const char rnp_driver_version[] = DRV_VERSION GIT_COMMIT; static const char rnp_copyright[] = "Copyright (c) 2020-2023 mucse Corporation."; - static struct rnp_info *rnp_info_tbl[] = { [board_n10] = &rnp_n10_info, [board_n400] = &rnp_n400_info, @@ -120,8 +119,7 @@ module_param(mpe_pkt_version, uint, 0000); MODULE_PARM_DESC(mpe_pkt_version, "ipv4 or ipv6 src port"); MODULE_AUTHOR("Mucse Corporation, "); -MODULE_DESCRIPTION( - "Mucse(R) 1/10/25/40 Gigabit PCI Express Network Driver"); +MODULE_DESCRIPTION("Mucse(R) 1/10/25/40 Gigabit PCI Express Network Driver"); MODULE_LICENSE("GPL"); MODULE_VERSION(DRV_VERSION); @@ -149,8 +147,8 @@ static void rnp_service_event_complete(struct rnp_adapter *adapter) * causes to vectors * * @adapter: pointer to adapter struct - * @queue: queue to map the corresponding interrupt to - * @msix_vector: the vector to map to the corresponding queue + * @rnp_queue: queue to map the corresponding interrupt to + * @rnp_msix_vector: the vector to map to the corresponding queue * */ static void rnp_set_ring_vector(struct rnp_adapter *adapter, u8 rnp_queue, @@ -171,9 +169,8 @@ static void rnp_set_ring_vector(struct rnp_adapter *adapter, u8 rnp_queue, rnp_wr_reg(hw->ring_msix_base + RING_VECTOR(rnp_queue), data); } - -void rnp_unmap_and_free_tx_resource(struct rnp_ring *ring, - struct rnp_tx_buffer *tx_buffer) +static void rnp_unmap_and_free_tx_resource(struct rnp_ring *ring, + struct rnp_tx_buffer *tx_buffer) { if (tx_buffer->skb) { dev_kfree_skb_any(tx_buffer->skb); @@ -218,8 +215,7 @@ static inline bool rnp_check_tx_hang(struct rnp_ring *tx_ring) clear_check_for_tx_hang(tx_ring); - /* - * Check for a hung queue, but be thorough. This verifies + /* Check for a hung queue, but be thorough. This verifies * that a transmit has been completed since the previous * check AND there is at least one packet pending. The * ARMED bit is set to indicate a potential hang. The @@ -230,7 +226,7 @@ static inline bool rnp_check_tx_hang(struct rnp_ring *tx_ring) * run the check_tx_hang logic with a transmit completion * pending but without time to complete it yet. */ - if ((tx_done_old == tx_done) && tx_pending) { + if (tx_done_old == tx_done && tx_pending) { /* make sure it is true for two checks in a row */ ret = test_and_set_bit(__RNP_HANG_CHECK_ARMED, &tx_ring->state); @@ -282,6 +278,7 @@ static void rnp_check_restart_tx(struct rnp_q_vector *q_vector, * rnp_clean_tx_irq - Reclaim resources after transmit completes * @q_vector: structure containing interrupt and ring information * @tx_ring: tx ring to clean + * @napi_budget: budget count **/ static bool rnp_clean_tx_irq(struct rnp_q_vector *q_vector, struct rnp_ring *tx_ring, int napi_budget) @@ -346,11 +343,10 @@ static bool rnp_clean_tx_irq(struct rnp_q_vector *q_vector, /* unmap any remaining paged data */ if (dma_unmap_len(tx_buffer, len)) { - dma_unmap_page( - tx_ring->dev, - dma_unmap_addr(tx_buffer, dma), - dma_unmap_len(tx_buffer, len), - DMA_TO_DEVICE); + dma_unmap_page(tx_ring->dev, + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); dma_unmap_len_set(tx_buffer, len, 0); } } @@ -460,8 +456,7 @@ static inline void rnp_update_rx_tail(struct rnp_ring *rx_ring, u32 val) rx_ring->next_to_use = val; /* update next to alloc since we have filled the ring */ rx_ring->next_to_alloc = val; - /* - * Force memory writes to complete before letting h/w + /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, * such as IA-64). @@ -470,7 +465,6 @@ static inline void rnp_update_rx_tail(struct rnp_ring *rx_ring, u32 val) rnp_wr_reg(rx_ring->tail, val); } - #if (PAGE_SIZE < 8192) #define RNP_MAX_2K_FRAME_BUILD_SKB (RNP_RXBUFFER_1536 - NET_IP_ALIGN) #define RNP_2K_TOO_SMALL_WITH_PADDING \ @@ -542,15 +536,17 @@ static void rnp_process_skb_fields(struct rnp_ring *rx_ring, /* check vlan type */ if (adapter->flags2 & RNP_FLAG2_VLAN_STAGS_ENABLED) { if (vid != adapter->stags_vid) { - __vlan_hwaccel_put_tag( - skb, htons(ETH_P_8021Q), vid); + __vlan_hwaccel_put_tag(skb, + htons(ETH_P_8021Q), + vid); } } else { - __vlan_hwaccel_put_tag( - skb, htons(ETH_P_8021Q), vid); + __vlan_hwaccel_put_tag(skb, + htons(ETH_P_8021Q), + vid); } + rx_ring->rx_stats.vlan_remove++; } - rx_ring->rx_stats.vlan_remove++; skb_record_rx_queue(skb, rx_ring->queue_index); @@ -580,7 +576,6 @@ static bool rnp_check_csum_error(struct rnp_ring *rx_ring, /* if rxcsum off nothing todo */ if (!(netdev->features & NETIF_F_RXCSUM)) return err; - if (unlikely(rnp_test_staterr(rx_desc, RNP_RXD_STAT_ERR_MASK))) { rx_debug_printk("rx error: VEB:%s mark:0x%x cmd:0x%x\n", (rx_ring->q_vector->adapter->flags & @@ -592,7 +587,7 @@ static bool rnp_check_csum_error(struct rnp_ring *rx_ring, rx_ring->rx_stats.csum_err++; if ((!(netdev->flags & IFF_PROMISC) && - (!(netdev->features & NETIF_F_RXALL)))) { + (!(netdev->features & NETIF_F_RXALL)))) { if (rx_ring->ring_flags & RNP_RING_CHKSM_FIX) { err = true; goto skip_fix; @@ -609,9 +604,9 @@ static bool rnp_check_csum_error(struct rnp_ring *rx_ring, /* we ignore sctp csum erro small than 60 */ if (unlikely(rnp_test_staterr(rx_desc, RNP_RXD_STAT_SCTP_MASK))) { - // sctp mask only valid if size > 60 and with ipv4 - if ((size > 60) && (rx_desc->wb.rev1 & - RNP_RX_L3_TYPE_MASK)) { + /* sctp mask only valid if size > 60 and with ipv4 */ + if (size > 60 && (rx_desc->wb.rev1 & + RNP_RX_L3_TYPE_MASK)) { err = true; } else { /* sctp less than 60 hw report err by mistake */ @@ -644,8 +639,8 @@ static bool rnp_check_csum_error(struct rnp_ring *rx_ring, rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; dma_sync_single_range_for_cpu(rx_ring->dev, rx_buffer->dma, - rx_buffer->page_offset, size, - DMA_FROM_DEVICE); + rx_buffer->page_offset, size, + DMA_FROM_DEVICE); #if (PAGE_SIZE < 8192) rx_buffer->page_offset ^= truesize; #else @@ -665,10 +660,11 @@ static bool rnp_check_csum_error(struct rnp_ring *rx_ring, /** * rnp_rx_ring_reinit - just reinit rx_ring with new count in ->reset_count + * @adapter: pointer to adapter struct * @rx_ring: rx descriptor ring to transact packets on */ -int rnp_rx_ring_reinit(struct rnp_adapter *adapter, - struct rnp_ring *rx_ring) +static int rnp_rx_ring_reinit(struct rnp_adapter *adapter, + struct rnp_ring *rx_ring) { struct rnp_ring *temp_ring; int err = 0; @@ -808,8 +804,7 @@ static unsigned int rnp_get_headlen(unsigned char *data, hdr.network += sizeof(struct udphdr); } - /* - * If everything has gone correctly hdr.network should be the + /* If everything has gone correctly hdr.network should be the * data section of the packet and will be the end of the header. * If not then it probably represents the end of the last recognized * header. @@ -820,7 +815,6 @@ static unsigned int rnp_get_headlen(unsigned char *data, return max_len; } - static inline bool rnp_page_is_reserved(struct page *page) { return (page_to_nid(page) != numa_mem_id()) || @@ -845,8 +839,7 @@ static bool rnp_can_reuse_rx_page(struct rnp_rx_buffer *rx_buffer) return false; #else - /* - * The last offset is a bit aggressive in that we assume the + /* The last offset is a bit aggressive in that we assume the * worst case of FCoE being enabled and using a 3K buffer. * However this should have minimal impact as the 1K extra is * still less than one buffer in size. @@ -887,8 +880,7 @@ static void rnp_reuse_rx_page(struct rnp_ring *rx_ring, nta++; rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0; - /* - * Transfer page from old buffer to new buffer. + /* Transfer page from old buffer to new buffer. * Move each member individually to avoid possible store * forwarding stalls and unnecessary copy of skb. */ @@ -945,14 +937,14 @@ static bool rnp_check_src_mac(struct sk_buff *skb, if (is_multicast_ether_addr(data)) { if (memcmp(data + netdev->addr_len, netdev->dev_addr, - netdev->addr_len) == 0) { + netdev->addr_len) == 0) { dev_kfree_skb_any(skb); ret = true; } /* if src mac equal own mac */ netdev_for_each_uc_addr(ha, netdev) { if (memcmp(data + netdev->addr_len, ha->addr, - netdev->addr_len) == 0) { + netdev->addr_len) == 0) { dev_kfree_skb_any(skb); ret = true; } @@ -1028,11 +1020,11 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) rx_desc = RNP_RX_DESC(rx_ring, i); - BUG_ON(rx_desc == NULL); + BUG_ON(!rx_desc); bi = &rx_ring->rx_buffer_info[i]; - BUG_ON(bi == NULL); + BUG_ON(!bi); i -= rx_ring->count; bufsz = rnp_rx_bufsz(rx_ring); @@ -1043,7 +1035,7 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) /* alloc page and init first rx_desc */ if (!rnp_alloc_mapped_page(rx_ring, bi, rx_desc, bufsz, - fun_id)) + fun_id)) break; page = bi->page; rx_desc->resv_cmd = 0; @@ -1069,9 +1061,9 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) rnp_rx_offset(rx_ring); /* map page for use */ dma = dma_map_page_attrs(rx_ring->dev, page, - bi->page_offset, bufsz, - DMA_FROM_DEVICE, - RNP_RX_DMA_ATTR); + bi->page_offset, bufsz, + DMA_FROM_DEVICE, + RNP_RX_DMA_ATTR); if (dma_mapping_error(rx_ring->dev, dma)) { rx_ring->rx_stats.alloc_rx_page_failed++; @@ -1083,11 +1075,10 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) bi->pagecnt_bias = USHRT_MAX; /* sync the buffer for use by the device */ dma_sync_single_range_for_device(rx_ring->dev, - bi->dma, 0, bufsz, - DMA_FROM_DEVICE); + bi->dma, 0, bufsz, + DMA_FROM_DEVICE); - /* - * Refresh the desc even if buffer_addrs didn't change + /* Refresh the desc even if buffer_addrs didn't change * because each write-back erases this info. */ rx_desc->pkt_addr = cpu_to_le64(bi->dma + fun_id); @@ -1118,7 +1109,6 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) * rnp_is_non_eop - process handling of non-EOP buffers * @rx_ring: Rx ring being processed * @rx_desc: Rx descriptor for current buffer - * @skb: Current socket buffer containing buffer in progress * * This function updates next to clean. If the buffer is an EOP buffer * this function exits returning false, otherwise it will place the @@ -1168,8 +1158,7 @@ static bool rnp_alloc_mapped_page(struct rnp_ring *rx_ring, bufsz, DMA_FROM_DEVICE, RNP_RX_DMA_ATTR); - /* - * if mapping failed free memory back to system since + /* if mapping failed free memory back to system since * there isn't much point in holding memory we can't use */ if (dma_mapping_error(rx_ring->dev, dma)) { @@ -1189,8 +1178,7 @@ static bool rnp_alloc_mapped_page(struct rnp_ring *rx_ring, dma_sync_single_range_for_device(rx_ring->dev, bi->dma, 0, bufsz, DMA_FROM_DEVICE); - /* - * Refresh the desc even if buffer_addrs didn't change + /* Refresh the desc even if buffer_addrs didn't change * because each write-back erases this info. */ rx_desc->pkt_addr = cpu_to_le64(bi->dma + fun_id); @@ -1229,11 +1217,11 @@ static void rnp_put_rx_buffer(struct rnp_ring *rx_ring, } else { /* we are not reusing the buffer so unmap it */ dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, - rnp_rx_bufsz(rx_ring), - DMA_FROM_DEVICE, - RNP_RX_DMA_ATTR); + rnp_rx_bufsz(rx_ring), + DMA_FROM_DEVICE, + RNP_RX_DMA_ATTR); __page_frag_cache_drain(rx_buffer->page, - rx_buffer->pagecnt_bias); + rx_buffer->pagecnt_bias); } /* clear contents of rx_buffer */ @@ -1272,7 +1260,6 @@ static struct sk_buff *rnp_construct_skb(struct rnp_ring *rx_ring, size -= headlen; if (size) { - skb_add_rx_frag(skb, 0, rx_buffer->page, (va + headlen) - page_address(rx_buffer->page), size, truesize); @@ -1361,17 +1348,16 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, */ dma_rmb(); - rx_debug_printk( - "queue:%d rx-desc:%d has-data len:%d next_to_clean %d\n", - rx_ring->rnp_queue_idx, rx_ring->next_to_clean, - rx_desc->wb.len, rx_ring->next_to_clean); + rx_debug_printk("queue:%d rx-desc:%d has-data len:%d ntc %d\n", + rx_ring->rnp_queue_idx, rx_ring->next_to_clean, + rx_desc->wb.len, rx_ring->next_to_clean); /* handle padding */ if ((adapter->priv_flags & RNP_PRIV_FLAG_FT_PADDING) && (!(adapter->priv_flags & RNP_PRIV_FLAG_PADDING_DEBUG))) { if (likely(rnp_test_staterr(rx_desc, - RNP_RXD_STAT_EOP))) { + RNP_RXD_STAT_EOP))) { size = le16_to_cpu(rx_desc->wb.len) - le16_to_cpu(rx_desc->wb.padding_len); } else { @@ -1385,8 +1371,7 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, if (!size) break; - /* - * should check csum err + /* should check csum err * maybe one packet use multiple descs * no problems hw set all csum_err in multiple descs * maybe BUG if the last sctp desc less than 60 @@ -1441,7 +1426,6 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, /* populate checksum, timestamp, VLAN, and protocol */ rnp_process_skb_fields(rx_ring, rx_desc, skb); - rnp_rx_skb(q_vector, skb); skb = NULL; @@ -1489,11 +1473,11 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) rx_desc = RNP_RX_DESC(rx_ring, i); - BUG_ON(rx_desc == NULL); + BUG_ON(!rx_desc); bi = &rx_ring->rx_buffer_info[i]; - BUG_ON(bi == NULL); + BUG_ON(!bi); i -= rx_ring->count; bufsz = rnp_rx_bufsz(rx_ring); @@ -1503,11 +1487,10 @@ void rnp_alloc_rx_buffers(struct rnp_ring *rx_ring, u16 cleaned_count) break; dma_sync_single_range_for_device(rx_ring->dev, bi->dma, - bi->page_offset, bufsz, - DMA_FROM_DEVICE); + bi->page_offset, bufsz, + DMA_FROM_DEVICE); - /* - * Refresh the desc even if buffer_addrs didn't change + /* Refresh the desc even if buffer_addrs didn't change * because each write-back erases this info. */ rx_desc->pkt_addr = @@ -1556,8 +1539,7 @@ static bool rnp_alloc_mapped_page(struct rnp_ring *rx_ring, rnp_rx_pg_size(rx_ring), DMA_FROM_DEVICE, RNP_RX_DMA_ATTR); - /* - * if mapping failed free memory back to system since + /* if mapping failed free memory back to system since * there isn't much point in holding memory we can't use */ if (dma_mapping_error(rx_ring->dev, dma)) { @@ -1774,7 +1756,6 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, unsigned int driver_drop_packets = 0; struct rnp_adapter *adapter = q_vector->adapter; u16 cleaned_count = rnp_desc_unused_rx(rx_ring); - bool xdp_xmit = false; struct xdp_buff xdp; xdp.data = NULL; @@ -1808,20 +1789,18 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, */ dma_rmb(); - rx_debug_printk( - "queue:%d rx-desc:%d has-data len:%d next_to_clean %d\n", - rx_ring->rnp_queue_idx, rx_ring->next_to_clean, - rx_desc->wb.len, rx_ring->next_to_clean); + rx_debug_printk("queue:%d rx-desc:%d has-data len:%d ntc %d\n", + rx_ring->rnp_queue_idx, rx_ring->next_to_clean, + rx_desc->wb.len, rx_ring->next_to_clean); /* handle padding */ if ((adapter->priv_flags & RNP_PRIV_FLAG_FT_PADDING) && (!(adapter->priv_flags & RNP_PRIV_FLAG_PADDING_DEBUG))) { if (likely(rnp_test_staterr(rx_desc, - RNP_RXD_STAT_EOP))) { + RNP_RXD_STAT_EOP))) { size = le16_to_cpu(rx_desc->wb.len) - - le16_to_cpu( - rx_desc->wb.padding_len); + le16_to_cpu(rx_desc->wb.padding_len); } else { size = le16_to_cpu(rx_desc->wb.len); } @@ -1833,8 +1812,7 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, if (!size) break; - /* - * should check csum err + /* should check csum err * maybe one packet use multiple descs * no problems hw set all csum_err in multiple descs * maybe BUG if the last sctp desc less than 60 @@ -1862,7 +1840,6 @@ static int rnp_clean_rx_irq(struct rnp_q_vector *q_vector, if (IS_ERR(skb)) { if (PTR_ERR(skb) == -RNP_XDP_TX) { - xdp_xmit = true; rnp_rx_buffer_flip(rx_ring, rx_buffer, size); } else { @@ -1950,15 +1927,13 @@ static void rnp_pull_tail(struct sk_buff *skb) unsigned char *va; unsigned int pull_len; - /* - * it is valid to use page_address instead of kmap since we are + /* it is valid to use page_address instead of kmap since we are * working with pages allocated out of the lomem pool per * alloc_page(GFP_ATOMIC) */ va = skb_frag_address(frag); - /* - * we need the header to contain the greater of either ETH_HLEN or + /* we need the header to contain the greater of either ETH_HLEN or * 60 bytes if the skb->len is less than 60 for skb_pad. */ pull_len = rnp_get_headlen(va, RNP_RX_HDR_SIZE); @@ -1973,7 +1948,6 @@ static void rnp_pull_tail(struct sk_buff *skb) skb->tail += pull_len; } - /** * rnp_configure_msix - Configure MSI-X hardware * @adapter: board private structure @@ -1986,9 +1960,7 @@ static void rnp_configure_msix(struct rnp_adapter *adapter) struct rnp_q_vector *q_vector; int i; - /* - * configure ring-msix Registers table - */ + /* configure ring-msix Registers table */ for (i = 0; i < adapter->num_q_vectors; i++) { struct rnp_ring *ring; @@ -2000,29 +1972,6 @@ static void rnp_configure_msix(struct rnp_adapter *adapter) } } - -/** - * rnp_write_eitr - write EITR register in hardware specific way - * @q_vector: structure containing interrupt and ring information - * - * This function is made to be called by ethtool and by the driver - * when it needs to update EITR registers at runtime. Hardware - * specific quirks/differences are taken care of here. - */ -void rnp_write_eitr_rx(struct rnp_q_vector *q_vector) -{ - struct rnp_adapter *adapter = q_vector->adapter; - struct rnp_hw *hw = &adapter->hw; - u32 itr_reg = q_vector->itr_rx >> 2; - struct rnp_ring *ring; - - itr_reg = itr_reg * hw->usecstocount; - rnp_for_each_ring(ring, q_vector->rx) { - ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_TIMER, itr_reg); - } -} - - enum latency_range { lowest_latency = 0, low_latency = 1, @@ -2030,7 +1979,6 @@ enum latency_range { latency_invalid = 255 }; - static inline void rnp_irq_enable_queues(struct rnp_adapter *adapter, struct rnp_q_vector *q_vector) { @@ -2110,12 +2058,11 @@ static irqreturn_t rnp_msix_clean_rings(int irq, void *data) return IRQ_HANDLED; } - static void update_rx_count(int cleaned, struct rnp_q_vector *q_vector) { struct rnp_adapter *adapter = q_vector->adapter; - if ((!cleaned) || (cleaned == q_vector->new_rx_count)) + if (!cleaned || cleaned == q_vector->new_rx_count) return; if (cleaned < 5) { @@ -2270,7 +2217,7 @@ int rnp_poll(struct napi_struct *napi, int budget) if (q_vector->new_rx_count != q_vector->old_rx_count) { ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_PKTCNT, - q_vector->new_rx_count); + q_vector->new_rx_count); q_vector->old_rx_count = q_vector->new_rx_count; } @@ -2291,14 +2238,13 @@ int rnp_poll(struct napi_struct *napi, int budget) /* update rx count if need */ if (q_vector->new_rx_count != q_vector->old_rx_count) { ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_PKTCNT, - q_vector->new_rx_count); + q_vector->new_rx_count); q_vector->old_rx_count = q_vector->new_rx_count; } } return budget; } - if (likely(napi_complete_done(napi, work_done))) { if (!test_bit(__RNP_DOWN, &adapter->state)) { rnp_irq_enable_queues(adapter, q_vector); @@ -2309,7 +2255,7 @@ int rnp_poll(struct napi_struct *napi, int budget) if (q_vector->new_rx_count != q_vector->old_rx_count) { ring_wr32(ring, RNP_DMA_REG_RX_INT_DELAY_PKTCNT, - q_vector->new_rx_count); + q_vector->new_rx_count); q_vector->old_rx_count = q_vector->new_rx_count; } @@ -2387,7 +2333,7 @@ static int rnp_request_msix_irqs(struct rnp_adapter *adapter) { struct net_device *netdev = adapter->netdev; int err; - int i = 0; + int i = 0, m; DPRINTK(IFUP, INFO, "[%s] num_q_vectors:%d\n", __func__, adapter->num_q_vectors); @@ -2435,17 +2381,15 @@ static int rnp_request_msix_irqs(struct rnp_adapter *adapter) free_queue_irqs: while (i) { i--; - irq_set_affinity_hint( - adapter->msix_entries[i + adapter->q_vector_off].vector, - NULL); - free_irq(adapter->msix_entries[i + adapter->q_vector_off].vector, + m = i + adapter->q_vector_off; + irq_set_affinity_hint(adapter->msix_entries[m].vector, + NULL); + free_irq(adapter->msix_entries[m].vector, adapter->q_vector[i]); - irq_set_affinity_notifier( - adapter->msix_entries[i + adapter->q_vector_off].vector, - NULL); - irq_set_affinity_hint( - adapter->msix_entries[i + adapter->q_vector_off].vector, - NULL); + irq_set_affinity_notifier(adapter->msix_entries[m].vector, + NULL); + irq_set_affinity_hint(adapter->msix_entries[m].vector, + NULL); } return err; } @@ -2473,7 +2417,6 @@ static int rnp_free_msix_irqs(struct rnp_adapter *adapter) return 0; } - /** * rnp_request_irq - initialize interrupts * @adapter: board private structure @@ -2511,7 +2454,6 @@ static int rnp_request_irq(struct rnp_adapter *adapter) static void rnp_free_irq(struct rnp_adapter *adapter) { - if (adapter->flags & RNP_FLAG_MSIX_ENABLED) { rnp_free_msix_irqs(adapter); } else if (adapter->flags & RNP_FLAG_MSI_ENABLED) { @@ -2555,9 +2497,8 @@ int rnp_setup_tx_maxrate(struct rnp_ring *tx_ring, u64 max_rate, /** * rnp_tx_maxrate_own - callback to set the maximum per-queue bitrate - * @netdev: network interface device structure + * @adapter: board private structure * @queue_index: Tx queue to set - * @maxrate: desired maximum transmit bitrate Mbps **/ static int rnp_tx_maxrate_own(struct rnp_adapter *adapter, int queue_index) { @@ -2566,8 +2507,8 @@ static int rnp_tx_maxrate_own(struct rnp_adapter *adapter, int queue_index) u32 maxrate = adapter->max_rate[queue_index]; if (!maxrate) - return rnp_setup_tx_maxrate( - tx_ring, 0, adapter->hw.usecstocount * 1000000); + return rnp_setup_tx_maxrate(tx_ring, 0, + adapter->hw.usecstocount * 1000000); /* we need turn it to bytes/s */ real_rate = ((u64)maxrate * 1024 * 1024) / 8; rnp_setup_tx_maxrate(tx_ring, real_rate, @@ -2640,7 +2581,6 @@ void rnp_configure_tx_ring(struct rnp_adapter *adapter, } clear_bit(__RNP_HANG_CHECK_ARMED, &ring->state); - } /** @@ -2731,7 +2671,6 @@ void rnp_configure_rx_ring(struct rnp_adapter *adapter, adapter->rx_frames); rnp_alloc_rx_buffers(ring, rnp_desc_unused_rx(ring)); - } static void rnp_configure_virtualization(struct rnp_adapter *adapter) @@ -2773,7 +2712,6 @@ static void rnp_configure_virtualization(struct rnp_adapter *adapter) vf_ring = rnp_get_vf_ringnum(hw, i, 1); rnp_setup_ring_maxrate(adapter, vf_ring, real_rate); } - } static void rnp_set_rx_buffer_len(struct rnp_adapter *adapter) @@ -2795,11 +2733,11 @@ static void rnp_set_rx_buffer_len(struct rnp_adapter *adapter) #ifdef OPTM_WITH_LARGE rx_ring->rx_page_buf_nums = RNP_PAGE_BUFFER_NUMS(rx_ring); - rx_ring->rx_per_buf_mem = ALIGN( - (rnp_rx_offset(rx_ring) + rnp_rx_bufsz(rx_ring) + - SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + - RNP_RX_HWTS_OFFSET), - 1024); + rx_ring->rx_per_buf_mem = ALIGN((rnp_rx_offset(rx_ring) + + rnp_rx_bufsz(rx_ring) + + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + + RNP_RX_HWTS_OFFSET), + 1024); #endif /* OPTM_WITH_LARGE */ } } @@ -2815,15 +2753,14 @@ static void rnp_configure_rx(struct rnp_adapter *adapter) struct rnp_hw *hw = &adapter->hw; struct rnp_dma_info *dma = &hw->dma; int i; - u32 rxctrl = 0, dma_axi_ctl; + u32 dma_axi_ctl; /* disable receives while setting up the descriptors */ /* set_rx_buffer_len must be called before ring initialization */ rnp_set_rx_buffer_len(adapter); - /* - * Setup the HW Rx Head and Tail Descriptor Pointers and + /* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring */ for (i = 0; i < adapter->num_rx_queues; i++) @@ -2831,18 +2768,15 @@ static void rnp_configure_rx(struct rnp_adapter *adapter) if (adapter->num_rx_queues > 0) { wr32(hw, RNP_ETH_DEFAULT_RX_RING, - adapter->rx_ring[0]->rnp_queue_idx); + adapter->rx_ring[0]->rnp_queue_idx); } /* enable all receives */ - rxctrl |= 0; - dma_axi_ctl = dma_rd32(dma, RNP_DMA_AXI_EN); dma_axi_ctl |= RX_AXI_RW_EN; dma_wr32(dma, RNP_DMA_AXI_EN, dma_axi_ctl); } - static int rnp_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto, u16 vid) { @@ -2851,13 +2785,12 @@ static int rnp_vlan_rx_add_vid(struct net_device *netdev, bool veb_setup = true; bool sriov_flag = !!(adapter->flags & RNP_FLAG_SRIOV_ENABLED); - if (sriov_flag) { /* in sriov mode */ - if ((vid) && (adapter->vf_vlan) && - (vid != adapter->vf_vlan)) { + if ((vid) && adapter->vf_vlan && + vid != adapter->vf_vlan) { dev_err(&adapter->pdev->dev, - "only 1 vlan in sriov mode\n"); + "only 1 vlan in sriov mode\n"); return -EACCES; } @@ -2865,14 +2798,14 @@ static int rnp_vlan_rx_add_vid(struct net_device *netdev, if (vid) { adapter->vf_vlan = vid; if (hw->ops.set_vf_vlan_mode) { - if (hw->feature_flags & - RNP_NET_FEATURE_VF_FIXED) - hw->ops.set_vf_vlan_mode( - hw, vid, 0, true); - else - hw->ops.set_vf_vlan_mode( - hw, vid, hw->vfnum, - true); + if (hw->feature_flags & RNP_NET_FEATURE_VF_FIXED) { + hw->ops.set_vf_vlan_mode(hw, vid, + 0, true); + } else { + hw->ops.set_vf_vlan_mode(hw, vid, + hw->vfnum, + true); + } } } } @@ -2912,7 +2845,6 @@ static int rnp_vlan_rx_kill_vid(struct net_device *netdev, if (!vid) return 0; - if (sriov_flag) { int true_remove = 1; @@ -2935,7 +2867,7 @@ static int rnp_vlan_rx_kill_vid(struct net_device *netdev, } if (true_remove) { if ((adapter->flags2 & RNP_FLAG2_VLAN_STAGS_ENABLED) && - (vid != adapter->stags_vid)) + vid != adapter->stags_vid) hw->ops.set_vlan_filter(hw, vid, false, veb_setup); } @@ -2947,8 +2879,8 @@ static int rnp_vlan_rx_kill_vid(struct net_device *netdev, if (hw->feature_flags & RNP_NET_FEATURE_VF_FIXED) hw->ops.set_vf_vlan_mode(hw, vid, 0, false); else - hw->ops.set_vf_vlan_mode( - hw, vid, hw->vfnum, false); + hw->ops.set_vf_vlan_mode(hw, vid, + hw->vfnum, false); } } else { int true_remove = 0; @@ -2959,9 +2891,8 @@ static int rnp_vlan_rx_kill_vid(struct net_device *netdev, true_remove = 1; } if (true_remove) { - if ((adapter->flags2 & - RNP_FLAG2_VLAN_STAGS_ENABLED) && - (vid != adapter->stags_vid)) + if ((adapter->flags2 & RNP_FLAG2_VLAN_STAGS_ENABLED) && + vid != adapter->stags_vid) hw->ops.set_vlan_filter(hw, vid, false, false); } } @@ -2980,8 +2911,6 @@ static int rnp_vlan_rx_kill_vid(struct net_device *netdev, return 0; } - - /** * rnp_vlan_strip_disable - helper to disable hw vlan stripping * @adapter: driver data @@ -3056,7 +2985,6 @@ static void rnp_restore_vlan(struct rnp_adapter *adapter) } } - /** * rnp_set_rx_mode - Unicast, Multicast and Promiscuous mode set * @netdev: network interface device structure @@ -3165,7 +3093,6 @@ static void rnp_fdir_filter_restore(struct rnp_adapter *adapter) spin_unlock(&adapter->fdir_perfect_lock); } - static void rnp_configure_pause(struct rnp_adapter *adapter) { struct rnp_hw *hw = &adapter->hw; @@ -3173,7 +3100,7 @@ static void rnp_configure_pause(struct rnp_adapter *adapter) hw->ops.set_pause_mode(hw); } -void rnp_vlan_stags_flag(struct rnp_adapter *adapter) +static void rnp_vlan_stags_flag(struct rnp_adapter *adapter) { struct rnp_hw *hw = &adapter->hw; @@ -3184,7 +3111,6 @@ void rnp_vlan_stags_flag(struct rnp_adapter *adapter) hw->ops.set_txvlan_mode(hw, true); } - static void rnp_configure(struct rnp_adapter *adapter) { struct rnp_hw *hw = &adapter->hw; @@ -3193,8 +3119,7 @@ static void rnp_configure(struct rnp_adapter *adapter) struct rnp_ring *rx_ring = adapter->rx_ring[0]; #endif - /* - * We must restore virtualization before VLANs or else + /* We must restore virtualization before VLANs or else * the VLVF registers will not be populated */ rnp_configure_virtualization(adapter); @@ -3246,8 +3171,7 @@ static inline bool rnp_is_sfp(struct rnp_hw *hw) **/ static void rnp_sfp_link_config(struct rnp_adapter *adapter) { - /* - * We are assuming the worst case scenario here, and that + /* We are assuming the worst case scenario here, and that * is that an SFP was inserted/removed after the reset * but before SFP detection was enabled. As such the best * solution is to just start searching as soon as we start @@ -3255,7 +3179,6 @@ static void rnp_sfp_link_config(struct rnp_adapter *adapter) adapter->flags2 |= RNP_FLAG2_SFP_NEEDS_RESET; } - static void rnp_up_complete(struct rnp_adapter *adapter) { struct rnp_hw *hw = &adapter->hw; @@ -3302,8 +3225,7 @@ void rnp_reinit_locked(struct rnp_adapter *adapter) while (test_and_set_bit(__RNP_RESETTING, &adapter->state)) usleep_range(1000, 2000); rnp_down(adapter); - /* - * If SR-IOV enabled then wait a bit before bringing the adapter + /* If SR-IOV enabled then wait a bit before bringing the adapter * back up to give the VFs time to respond to the reset. The * two second wait is based upon the watchdog timer cycle in * the VF driver. @@ -3471,7 +3393,7 @@ static void rnp_clean_tx_ring(struct rnp_ring *tx_ring) u16 i = tx_ring->next_to_clean; struct rnp_tx_buffer *tx_buffer = &tx_ring->tx_buffer_info[i]; - BUG_ON(tx_ring == NULL); + BUG_ON(!tx_ring); /* ring already cleared, nothing to do */ if (!tx_ring->tx_buffer_info) @@ -3503,9 +3425,9 @@ static void rnp_clean_tx_ring(struct rnp_ring *tx_ring) /* unmap any remaining paged data */ if (dma_unmap_len(tx_buffer, len)) dma_unmap_page(tx_ring->dev, - dma_unmap_addr(tx_buffer, dma), - dma_unmap_len(tx_buffer, len), - DMA_TO_DEVICE); + dma_unmap_addr(tx_buffer, dma), + dma_unmap_len(tx_buffer, len), + DMA_TO_DEVICE); } /* move us one more past the eop_desc for start of next pkt */ tx_buffer++; @@ -3577,8 +3499,8 @@ static void rnp_fdir_filter_exit(struct rnp_adapter *adapter) spin_unlock(&adapter->fdir_perfect_lock); } -int rnp_xmit_nop_frame_ring(struct rnp_adapter *adapter, - struct rnp_ring *tx_ring) +static int rnp_xmit_nop_frame_ring(struct rnp_adapter *adapter, + struct rnp_ring *tx_ring) { u16 i = tx_ring->next_to_use; struct rnp_tx_desc *tx_desc; @@ -3588,8 +3510,7 @@ int rnp_xmit_nop_frame_ring(struct rnp_adapter *adapter, /* set length to 0 */ tx_desc->blen_mac_ip_len = 0; tx_desc->vlan_cmd = cpu_to_le32(RNP_TXD_CMD_EOP | RNP_TXD_CMD_RS); - /* - * Force memory writes to complete before letting h/w know there + /* Force memory writes to complete before letting h/w know there * are new descriptors to fetch. (Only applicable for weak-ordered * memory model archs, such as IA-64). * @@ -3602,7 +3523,6 @@ int rnp_xmit_nop_frame_ring(struct rnp_adapter *adapter, return 0; } - void rnp_down(struct rnp_adapter *adapter) { struct net_device *netdev = adapter->netdev; @@ -3613,7 +3533,7 @@ void rnp_down(struct rnp_adapter *adapter) /* signal that we are down to the interrupt handler */ set_bit(__RNP_DOWN, &adapter->state); - if ((!hw->ncsi_en) && (!(adapter->flags & RNP_FLAG_SRIOV_ENABLED))) + if (!hw->ncsi_en && (!(adapter->flags & RNP_FLAG_SRIOV_ENABLED))) hw->ops.set_mac_rx(hw, false); hw->ops.set_mbx_link_event(hw, 0); @@ -3726,8 +3646,8 @@ void rnp_down(struct rnp_adapter *adapter) if (head != (count - 1)) { /* 3 set len head + 1 */ ring_wr32(tx_ring, - RNP_DMA_REG_TX_DESC_BUF_LEN, - head + 1); + RNP_DMA_REG_TX_DESC_BUF_LEN, + head + 1); } /* set to use head */ tx_ring->next_to_use = head; @@ -3735,15 +3655,14 @@ void rnp_down(struct rnp_adapter *adapter) rnp_xmit_nop_frame_ring(adapter, tx_ring); /* 5 wait head to zero */ while ((head != 0) && (timeout < 1000)) { - head = ring_rd32(tx_ring, - RNP_DMA_REG_TX_DESC_BUF_HEAD); + head = ring_rd32(tx_ring, RNP_DMA_REG_TX_DESC_BUF_HEAD); usleep_range(10000, 20000); timeout++; } if (timeout >= 1000) { e_err(drv, "[%s] Wait Tx-ring %d head to zero time out\n", - netdev->name, - tx_ring->rnp_queue_idx); + netdev->name, + tx_ring->rnp_queue_idx); } /* 6 stop queue again skip */ /* 7 write back next_to_use maybe hw hang */ @@ -3774,6 +3693,7 @@ void rnp_down(struct rnp_adapter *adapter) /** * rnp_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure + * @txqueue: queue idx **/ static void rnp_tx_timeout(struct net_device *netdev, unsigned int txqueue) { @@ -3797,7 +3717,7 @@ static void rnp_tx_timeout(struct net_device *netdev, unsigned int txqueue) rnp_tx_timeout_reset(adapter); } else { e_err(drv, "Fake Tx hang detected with timeout of %d seconds\n", - netdev->watchdog_timeo / HZ); + netdev->watchdog_timeo / HZ); /* fake Tx hang - increase the kernel timeout */ if (netdev->watchdog_timeo < TX_TIMEO_LIMIT) @@ -3823,7 +3743,6 @@ static int rnp_sw_init(struct rnp_adapter *adapter) rss_limit = RNP_MAX_RINGS; #endif /* RNP_MAX_RINGS */ - hw->vendor_id = pdev->vendor; hw->device_id = pdev->device; hw->subsystem_vendor_id = pdev->subsystem_vendor; @@ -3878,11 +3797,11 @@ static int rnp_sw_init(struct rnp_adapter *adapter) /** * rnp_setup_tx_resources - allocate Tx resources (Descriptors) - * @tx_ring: tx descriptor ring (for a specific queue) to setup + * @tx_ring: tx descriptor ring (for a specific queue) to setup + * @adapter: adapter * * Return 0 on success, negative on failure **/ - int rnp_setup_tx_resources(struct rnp_ring *tx_ring, struct rnp_adapter *adapter) { @@ -3909,8 +3828,9 @@ int rnp_setup_tx_resources(struct rnp_ring *tx_ring, &tx_ring->dma, GFP_KERNEL); set_dev_node(dev, orig_node); if (!tx_ring->desc) - tx_ring->desc = dma_alloc_coherent( - dev, tx_ring->size, &tx_ring->dma, GFP_KERNEL); + tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, + &tx_ring->dma, + GFP_KERNEL); if (!tx_ring->desc) goto err; memset(tx_ring->desc, 0, tx_ring->size); @@ -3953,7 +3873,7 @@ static int rnp_setup_all_tx_resources(struct rnp_adapter *adapter) adapter->num_tx_queues, adapter->tx_ring[0]); for (i = 0; i < (adapter->num_tx_queues); i++) { - BUG_ON(adapter->tx_ring[i] == NULL); + BUG_ON(!adapter->tx_ring[i]); err = rnp_setup_tx_resources(adapter->tx_ring[i], adapter); if (!err) continue; @@ -3972,7 +3892,8 @@ static int rnp_setup_all_tx_resources(struct rnp_adapter *adapter) /** * rnp_setup_rx_resources - allocate Rx resources (Descriptors) - * @rx_ring: rx descriptor ring (for a specific queue) to setup + * @rx_ring: rx descriptor ring (for a specific queue) to setup + * @adapter: board private structure * * Returns 0 on success, negative on failure **/ @@ -3984,7 +3905,7 @@ int rnp_setup_rx_resources(struct rnp_ring *rx_ring, int numa_node = NUMA_NO_NODE; int size; - BUG_ON(rx_ring == NULL); + BUG_ON(!rx_ring); size = sizeof(struct rnp_rx_buffer) * rx_ring->count; @@ -4005,8 +3926,9 @@ int rnp_setup_rx_resources(struct rnp_ring *rx_ring, &rx_ring->dma, GFP_KERNEL); set_dev_node(dev, orig_node); if (!rx_ring->desc) - rx_ring->desc = dma_alloc_coherent( - dev, rx_ring->size, &rx_ring->dma, GFP_KERNEL); + rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, + &rx_ring->dma, + GFP_KERNEL); if (!rx_ring->desc) goto err; memset(rx_ring->desc, 0, rx_ring->size); @@ -4015,10 +3937,10 @@ int rnp_setup_rx_resources(struct rnp_ring *rx_ring, rx_ring->next_to_use = 0; DPRINTK(IFUP, INFO, "RxRing:%d, vector:%d ItemCounts:%d", - rx_ring->rnp_queue_idx, rx_ring->q_vector->v_idx, - rx_ring->count); + rx_ring->rnp_queue_idx, rx_ring->q_vector->v_idx, + rx_ring->count); DPRINTK(IFUP, INFO, "desc:%p(0x%llx) node:%d\n", - rx_ring->desc, (u64)rx_ring->dma, numa_node); + rx_ring->desc, (u64)rx_ring->dma, numa_node); return 0; err: @@ -4045,7 +3967,7 @@ static int rnp_setup_all_rx_resources(struct rnp_adapter *adapter) u32 head; for (i = 0; i < adapter->num_rx_queues; i++) { - BUG_ON(adapter->rx_ring[i] == NULL); + BUG_ON(!adapter->rx_ring[i]); /* should check count and head */ /* in sriov condition may head large than count */ @@ -4085,7 +4007,7 @@ static int rnp_setup_all_rx_resources(struct rnp_adapter *adapter) **/ void rnp_free_tx_resources(struct rnp_ring *tx_ring) { - BUG_ON(tx_ring == NULL); + BUG_ON(!tx_ring); rnp_clean_tx_ring(tx_ring); vfree(tx_ring->tx_buffer_info); @@ -4123,7 +4045,7 @@ static void rnp_free_all_tx_resources(struct rnp_adapter *adapter) **/ void rnp_free_rx_resources(struct rnp_ring *rx_ring) { - BUG_ON(rx_ring == NULL); + BUG_ON(!rx_ring); rnp_clean_rx_ring(rx_ring); @@ -4169,7 +4091,7 @@ static int rnp_change_mtu(struct net_device *netdev, int new_mtu) int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN * 2; /* MTU < 68 is an error and causes problems on some kernels */ - if ((new_mtu < hw->min_length) || (max_frame > hw->max_length)) + if (new_mtu < hw->min_length || max_frame > hw->max_length) return -EINVAL; e_info(probe, "changing MTU from %d to %d\n", netdev->mtu, @@ -4196,7 +4118,7 @@ static int rnp_change_mtu(struct net_device *netdev, int new_mtu) * @maxrate: desired maximum transmit bitrate Mbps **/ static int rnp_tx_maxrate(struct net_device *netdev, - int queue_index, u32 maxrate) + int queue_index, u32 maxrate) { struct rnp_adapter *adapter = netdev_priv(netdev); struct rnp_ring *tx_ring = adapter->tx_ring[queue_index]; @@ -4206,8 +4128,8 @@ static int rnp_tx_maxrate(struct net_device *netdev, rnp_dbg("%s: queue:%d maxrate:%d\n", __func__, queue_index, maxrate); if (!maxrate) - return rnp_setup_tx_maxrate( - tx_ring, 0, adapter->hw.usecstocount * 1000000); + return rnp_setup_tx_maxrate(tx_ring, 0, + adapter->hw.usecstocount * 1000000); /* we need turn it to bytes/s */ real_rate = ((u64)maxrate * 1024 * 1024) / 8; rnp_setup_tx_maxrate(tx_ring, real_rate, @@ -4333,8 +4255,7 @@ static int __maybe_unused rnp_resume(struct device *dev_d) pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); - /* - * pci_restore_state clears dev->state_saved so call + /* pci_restore_state clears dev->state_saved so call * pci_save_state to restore it. */ pci_save_state(pdev); @@ -4427,7 +4348,6 @@ static int __rnp_shutdown(struct pci_dev *pdev, bool *enable_wake) hw->ops.enable_tx_laser(hw); /* turn on all-multi mode if wake on multicast is enabled */ - } if (hw->ops.setup_wol) @@ -4447,7 +4367,6 @@ static int __maybe_unused rnp_suspend(struct device *dev_d) int retval; bool wake; - retval = __rnp_shutdown(pdev, &wake); if (retval) return retval; @@ -4473,6 +4392,7 @@ static void rnp_shutdown(struct pci_dev *pdev) pci_set_power_state(pdev, PCI_D3hot); } } + /** * rnp_update_stats - Update the board statistics counters. * @adapter: board private structure @@ -4519,9 +4439,9 @@ void rnp_update_stats(struct rnp_adapter *adapter) hw->ops.update_hw_status(hw, hw_stats, net_stats); - adapter->hw_csum_rx_error = hw_csum_rx_error; + adapter->hw_csum_rx_error = hw_csum_rx_error + hw_stats->mac_rx_csum_err; adapter->hw_csum_rx_good = hw_csum_rx_good; - net_stats->rx_errors = hw_csum_rx_error; + net_stats->rx_errors = adapter->hw_csum_rx_error; } /** @@ -4602,8 +4522,8 @@ static void rnp_check_hang_subtask(struct rnp_adapter *adapter) if (rx_next_to_clean == rx_next_to_clean_old) { rx_ring->rx_stats.rx_equal_count++; - if ((rx_ring->rx_stats.rx_equal_count > 2) && - (rx_ring->rx_stats.rx_equal_count < 5)) { + if (rx_ring->rx_stats.rx_equal_count > 2 && + rx_ring->rx_stats.rx_equal_count < 5) { int size; struct rnp_q_vector *q_vector; /* check if dd in the clean rx desc */ @@ -4637,7 +4557,6 @@ static void rnp_check_hang_subtask(struct rnp_adapter *adapter) /** * rnp_watchdog_update_link - update the link status * @adapter: pointer to the device adapter structure - * @link_speed: pointer to a u32 to store the link_speed **/ static void rnp_watchdog_update_link(struct rnp_adapter *adapter) { @@ -4715,7 +4634,6 @@ static void rnp_watchdog_update_link(struct rnp_adapter *adapter) default: speed_str = "unknown speed"; break; - } /* if we detect changed link setup new */ if (adapter->link_up) { @@ -4738,7 +4656,6 @@ static void rnp_watchdog_update_link(struct rnp_adapter *adapter) } } - /** * rnp_watchdog_link_is_up - update netif_carrier status and * print link up message @@ -4797,8 +4714,8 @@ static void rnp_update_link_to_vf(struct rnp_adapter *adapter) if (!(adapter->flags & RNP_FLAG_VF_INIT_DONE)) return; - if ((adapter->link_up_old != adapter->link_up) || - (adapter->link_speed_old != adapter->link_speed)) { + if (adapter->link_up_old != adapter->link_up || + adapter->link_speed_old != adapter->link_speed) { /* if change send mbx to all vf */ if (!test_bit(__RNP_IN_IRQ, &adapter->state)) { if (rnp_msg_post_status(adapter, @@ -4810,6 +4727,7 @@ static void rnp_update_link_to_vf(struct rnp_adapter *adapter) } } } + /** * rnp_watchdog_subtask - check and bring link up * @adapter: pointer to the device adapter structure @@ -4831,15 +4749,13 @@ static void rnp_watchdog_subtask(struct rnp_adapter *adapter) rnp_update_link_to_vf(adapter); rnp_update_stats(adapter); - } - /** * rnp_service_timer - Timer Call-back - * @data: pointer to adapter cast into an unsigned long + * @t: pointer to adapter cast into an unsigned long **/ -void rnp_service_timer(struct timer_list *t) +static void rnp_service_timer(struct timer_list *t) { struct rnp_adapter *adapter = from_timer(adapter, t, service_timer); @@ -4947,7 +4863,7 @@ static void rnp_rx_len_reset_subtask(struct rnp_adapter *adapter) * rnp_service_task - manages and runs subtasks * @work: pointer to work_struct containing our data **/ -void rnp_service_task(struct work_struct *work) +static void rnp_service_task(struct work_struct *work) { struct rnp_adapter *adapter = container_of(work, struct rnp_adapter, service_task); @@ -5033,7 +4949,6 @@ static int rnp_tso(struct rnp_ring *tx_ring, struct rnp_tx_buffer *first, l4.hdr = skb_inner_transport_header(skb); } - if (ip.v4->version == 4) { /* IP header will have to cancel out any data that * is not a part of the outer IP header @@ -5219,7 +5134,7 @@ static int rnp_tx_csum(struct rnp_ring *tx_ring, } if ((tx_ring->ring_flags & RNP_RING_NO_TUNNEL_SUPPORT) && - (first->ctx_flag)) { + first->ctx_flag) { *tx_flags &= (~RNP_TXD_TUNNEL_MASK); if (!(first->priv_tags)) { first->ctx_flag = false; @@ -5349,8 +5264,7 @@ static int rnp_tx_map(struct rnp_ring *tx_ring, netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); #endif /* NO_BQL_TEST */ - /* - * Force memory writes to complete before letting h/w know there + /* Force memory writes to complete before letting h/w know there * are new descriptors to fetch. (Only applicable for weak-ordered * memory model archs, such as IA-64). * @@ -5407,7 +5321,6 @@ static int rnp_tx_map(struct rnp_ring *tx_ring, return -1; } - static void rnp_force_src_mac(struct sk_buff *skb, struct net_device *netdev) { @@ -5417,13 +5330,13 @@ static void rnp_force_src_mac(struct sk_buff *skb, /* force all multicast / broadcast src mac to myself */ if (is_multicast_ether_addr(data)) { if (memcmp(data + netdev->addr_len, netdev->dev_addr, - netdev->addr_len) == 0) { + netdev->addr_len) == 0) { ret = true; goto DONE; } netdev_for_each_uc_addr(ha, netdev) { if (memcmp(data + netdev->addr_len, ha->addr, - netdev->addr_len) == 0) { + netdev->addr_len) == 0) { ret = true; /* if it is src mac, nothing todo */ goto DONE; @@ -5458,8 +5371,7 @@ netdev_tx_t rnp_xmit_frame_ring(struct sk_buff *skb, skb->len, skb_headlen(skb), skb->data_len); tx_dbg("next_to_clean %d, next_to_use %d\n", tx_ring->next_to_clean, tx_ring->next_to_use); - /* - * need: 1 descriptor per page * PAGE_SIZE/RNP_MAX_DATA_PER_TXD, + /* need: 1 descriptor per page * PAGE_SIZE/RNP_MAX_DATA_PER_TXD, * + 1 desc for skb_headlen/RNP_MAX_DATA_PER_TXD, * + 2 desc gap to keep tail from touching head, * + 1 desc for context descriptor, @@ -5696,8 +5608,7 @@ static netdev_tx_t rnp_xmit_frame(struct sk_buff *skb, return NETDEV_TX_OK; } - /* - * The minimum packet size for olinfo paylen is 17 so pad the skb + /* The minimum packet size for olinfo paylen is 17 so pad the skb * in order to meet this minimum size requirement. */ if (adapter->priv_flags & RNP_PRIV_FLAG_TX_PADDING) { @@ -5783,7 +5694,7 @@ static int rnp_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, if (cmd == SIOCGMIIREG) { ret = rnp_mdio_read(netdev, prtad, devad, mii->reg_num, - &phy_value); + &phy_value); if (ret < 0) return ret; mii->val_out = phy_value; @@ -5811,7 +5722,7 @@ static int rnp_ioctl(struct net_device *netdev, struct ifreq *req, int cmd) case SIOCGMIIPHY: return 0; case SIOCGMIIREG: - /*fall through */ + fallthrough; case SIOCSMIIREG: return rnp_mii_ioctl(netdev, req, cmd); } @@ -5819,7 +5730,7 @@ static int rnp_ioctl(struct net_device *netdev, struct ifreq *req, int cmd) } #ifdef CONFIG_NET_POLL_CONTROLLER -/* +/** * Polling 'interrupt' - used by things like netconsole to send skbs * without having to re-enable interrupts. It's not called while * the interrupt routine is executing. @@ -5855,8 +5766,7 @@ static void rnp_get_stats64(struct net_device *netdev, if (ring) { do { - start = u64_stats_fetch_begin( - &ring->syncp); + start = u64_stats_fetch_begin(&ring->syncp); packets = ring->stats.packets; bytes = ring->stats.bytes; } while (u64_stats_fetch_retry(&ring->syncp, @@ -5873,8 +5783,7 @@ static void rnp_get_stats64(struct net_device *netdev, if (ring) { do { - start = u64_stats_fetch_begin( - &ring->syncp); + start = u64_stats_fetch_begin(&ring->syncp); packets = ring->stats.packets; bytes = ring->stats.bytes; } while (u64_stats_fetch_retry(&ring->syncp, @@ -5890,13 +5799,12 @@ static void rnp_get_stats64(struct net_device *netdev, stats->rx_length_errors = netdev->stats.rx_length_errors; stats->rx_crc_errors = netdev->stats.rx_crc_errors; stats->rx_missed_errors = netdev->stats.rx_missed_errors; - } /** * rnp_setup_tc - configure net_device for multiple traffic classes * - * @netdev: net device to configure + * @dev: net device to configure * @tc: number of traffic classes to enable */ int rnp_setup_tc(struct net_device *dev, u8 tc) @@ -5909,9 +5817,9 @@ int rnp_setup_tc(struct net_device *dev, u8 tc) return -EINVAL; /* Hardware supports up to 8 traffic classes */ - if ((tc > RNP_MAX_TCS_NUM) || (tc == 1)) + if (tc > RNP_MAX_TCS_NUM || tc == 1) return -EINVAL; - /* we canot support tc with sriov mode */ + /* we cannot support tc with sriov mode */ if ((tc) && (adapter->flags & RNP_FLAG_SRIOV_ENABLED)) return -EINVAL; @@ -5969,8 +5877,8 @@ void rnp_sriov_reinit(struct rnp_adapter *adapter) } #endif /* CONFIG_PCI_IOV */ -int rnp_delete_knode(struct net_device *dev, - struct tc_cls_u32_offload *cls) +static int rnp_delete_knode(struct net_device *dev, + struct tc_cls_u32_offload *cls) { /* 1. check weather filter rule is ingress root */ struct rnp_adapter *adapter = netdev_priv(dev); @@ -5978,7 +5886,7 @@ int rnp_delete_knode(struct net_device *dev, u32 uhtid = TC_U32_USERHTID(cls->knode.handle); int ret; - if ((uhtid != 0x800)) + if (uhtid != 0x800) return -EINVAL; spin_lock(&adapter->fdir_perfect_lock); @@ -5987,6 +5895,7 @@ int rnp_delete_knode(struct net_device *dev, return ret; } + #ifdef CONFIG_NET_CLS_ACT static int rnp_action_parse(struct tcf_exts *exts, u64 *action, u8 *queue) { @@ -6058,8 +5967,8 @@ static int rnp_clsu32_build_input(struct tc_cls_u32_offload *cls, return 0; } -int rnp_config_knode(struct net_device *dev, __be16 protocol, - struct tc_cls_u32_offload *cls) +static int rnp_config_knode(struct net_device *dev, __be16 protocol, + struct tc_cls_u32_offload *cls) { /*1. check ethernet hw-feature U32 can offload */ /*2. check U32 protocol We just support IPV4 offloading For now*/ @@ -6117,8 +6026,8 @@ int rnp_config_knode(struct net_device *dev, __be16 protocol, return -EOPNOTSUPP; } -int rnp_setup_tc_cls_u32(struct net_device *dev, - struct tc_cls_u32_offload *cls_u32) +static int rnp_setup_tc_cls_u32(struct net_device *dev, + struct tc_cls_u32_offload *cls_u32) { __be16 proto = cls_u32->common.protocol; @@ -6141,10 +6050,9 @@ static int rnp_setup_tc_block_ingress_cb(enum tc_setup_type type, struct rnp_adapter *adapter = netdev_priv(dev); if (test_bit(__RNP_DOWN, &adapter->state)) { - netdev_err( - adapter->netdev, - "Failed to setup tc on port %d. Link Down? 0x%.2lx\n", - adapter->port, adapter->state); + netdev_err(adapter->netdev, + "Failed to setup tc on port %d. Link Down? 0x%.2lx\n", + adapter->port, adapter->state); return -EINVAL; } if (!tc_cls_can_offload_and_chain0(dev, type_data)) @@ -6168,7 +6076,7 @@ static int rnp_setup_mqprio(struct net_device *dev, } static int __rnp_setup_tc(struct net_device *netdev, - enum tc_setup_type type, void *type_data) + enum tc_setup_type type, void *type_data) { struct rnp_adapter *adapter = netdev_priv(netdev); @@ -6176,14 +6084,15 @@ static int __rnp_setup_tc(struct net_device *netdev, case TC_SETUP_BLOCK: { struct flow_block_offload *f = (struct flow_block_offload *)type_data; - if (f->binder_type == - FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) - return flow_block_cb_setup_simple( - type_data, &rnp_block_cb_list, - rnp_setup_tc_block_ingress_cb, adapter, - adapter, true); - else + if (f->binder_type == FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) { + return flow_block_cb_setup_simple(type_data, + &rnp_block_cb_list, + rnp_setup_tc_block_ingress_cb, + adapter, + adapter, true); + } else { return -EOPNOTSUPP; + } } case TC_SETUP_QDISC_MQPRIO: return rnp_setup_mqprio(netdev, type_data); @@ -6194,7 +6103,7 @@ static int __rnp_setup_tc(struct net_device *netdev, return 0; } -void rnp_do_reset(struct net_device *netdev) +static void rnp_do_reset(struct net_device *netdev) { struct rnp_adapter *adapter = netdev_priv(netdev); @@ -6287,7 +6196,6 @@ static int rnp_set_features(struct net_device *netdev, /* rx fcs changed */ /* in this mode rx l4/sctp checksum will get error */ if (changed & NETIF_F_RXFCS) { - if (features & NETIF_F_RXFCS) { adapter->priv_flags |= RNP_PRIV_FLAG_RX_FCS; hw->ops.set_fcs_mode(hw, true); @@ -6351,9 +6259,9 @@ rnp_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, adapter->flags2 |= RNP_FLAG2_BRIDGE_MODE_VEB; wr32(hw, RNP_DMA_CONFIG, rd32(hw, RNP_DMA_CONFIG) & (~DMA_VEB_BYPASS)); - - } else + } else { return -EINVAL; + } e_info(drv, "enabling bridge mode: %s\n", mode == BRIDGE_MODE_VEPA ? "VEPA" : "VEB"); @@ -6382,7 +6290,6 @@ static int rnp_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, nlflags, filter_mask, NULL); } - #define RNP_MAX_TUNNEL_HDR_LEN 80 #define RNP_MAX_MAC_HDR_LEN 127 #define RNP_MAX_NETWORK_HDR_LEN 511 @@ -6449,7 +6356,7 @@ const struct net_device_ops rnp10_netdev_ops = { .ndo_fix_features = rnp_fix_features, }; -void rnp_assign_netdev_ops(struct net_device *dev) +static void rnp_assign_netdev_ops(struct net_device *dev) { /* different hw can assign difference fun */ dev->netdev_ops = &rnp10_netdev_ops; @@ -6458,9 +6365,9 @@ void rnp_assign_netdev_ops(struct net_device *dev) /** * rnp_wol_supported - Check whether device supports WoL - * @hw: hw specific details + * @adapter: adapter specific details * @device_id: the device ID - * @subdev_id: the subsystem device ID + * @subdevice_id: the subsystem device ID * * This function is used by probe and ethtool to determine * which devices have WoL support @@ -6478,29 +6385,14 @@ int rnp_wol_supported(struct rnp_adapter *adapter, u16 device_id, return is_wol_supported; } -static inline unsigned long rnp_tso_features(struct rnp_hw *hw) -{ - unsigned long features = 0; - - if (hw->feature_flags & RNP_NET_FEATURE_TSO) - features |= NETIF_F_TSO; - if (hw->feature_flags & RNP_NET_FEATURE_TSO) - features |= NETIF_F_TSO6; - features |= NETIF_F_GSO_PARTIAL; - if (hw->feature_flags & RNP_NET_FEATURE_TX_UDP_TUNNEL) - features |= RNP_GSO_PARTIAL_FEATURES; - - return features; -} - static void remove_mbx_irq(struct rnp_adapter *adapter) { /* mbx */ if (adapter->num_other_vectors) { if (adapter->flags & RNP_FLAG_MSIX_ENABLED) { - adapter->hw.mbx.ops.configure( - &adapter->hw, - adapter->msix_entries[0].entry, false); + adapter->hw.mbx.ops.configure(&adapter->hw, + adapter->msix_entries[0].entry, + false); free_irq(adapter->msix_entries[0].vector, adapter); adapter->hw.mbx.other_irq_enabled = false; @@ -6526,8 +6418,9 @@ static int register_mbx_irq(struct rnp_adapter *adapter) err); goto err_mbx; } - hw->mbx.ops.configure( - hw, adapter->msix_entries[0].entry, true); + hw->mbx.ops.configure(hw, + adapter->msix_entries[0].entry, + true); adapter->hw.mbx.other_irq_enabled = true; } } @@ -6604,10 +6497,9 @@ static void rnp_fix_dma_tx_status(struct rnp_adapter *adapter) struct rnp_hw *hw = &adapter->hw; struct rnp_dma_info *dma = &hw->dma; - if ((hw->hw_type == rnp_hw_n10) || (hw->hw_type == rnp_hw_n400)) { + if (hw->hw_type == rnp_hw_n10 || hw->hw_type == rnp_hw_n400) { for (i = 0; i < dma->max_tx_queues; i++) - dma_ring_wr32( - dma, RING_OFFSET(i) + RNP_DMA_TX_START, 1); + dma_ring_wr32(dma, RING_OFFSET(i) + RNP_DMA_TX_START, 1); } } @@ -6625,9 +6517,9 @@ static u8 rnp10_pfnum(u8 __iomem *hw_addr_bar0, struct pci_dev *pdev) return ((vf_num & VF_NUM_MASK_TEMP) >> VF_NUM_OFF); } -int rnp_can_rpu_start(struct rnp_adapter *adapter) +static int rnp_can_rpu_start(struct rnp_adapter *adapter) { - if (adapter->hw.rpu_addr == NULL) + if (!adapter->hw.rpu_addr) return 0; if ((adapter->pdev->device & 0xff00) == 0x1c00) return 1; @@ -6697,7 +6589,7 @@ static int rnp_add_adpater(struct pci_dev *pdev, struct rnp_info *ii, /* n10 use bar4 */ #define RNP_NIC_BAR_N10 4 hw_addr = ioremap(pci_resource_start(pdev, RNP_NIC_BAR_N10), - pci_resource_len(pdev, RNP_NIC_BAR_N10)); + pci_resource_len(pdev, RNP_NIC_BAR_N10)); if (!hw_addr) { dev_err(&pdev->dev, "pcim_iomap bar%d failed!\n", RNP_NIC_BAR_N10); @@ -6705,8 +6597,8 @@ static int rnp_add_adpater(struct pci_dev *pdev, struct rnp_info *ii, } pr_info("[bar%d]:%p %llx len=%d MB\n", RNP_NIC_BAR_N10, hw_addr, - (unsigned long long)pci_resource_start( - pdev, RNP_NIC_BAR_N10), + (unsigned long long)pci_resource_start(pdev, + RNP_NIC_BAR_N10), (int)pci_resource_len(pdev, RNP_NIC_BAR_N10) / 1024 / 1024); /* get dma version */ @@ -6785,8 +6677,8 @@ static int rnp_add_adpater(struct pci_dev *pdev, struct rnp_info *ii, memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops)); if (dma_version >= 0x20210111) { rnp_mbx_link_event_enable(hw, 0); - if ((hw->hw_type == rnp_hw_n10) || - (hw->hw_type == rnp_hw_n400)) + if (hw->hw_type == rnp_hw_n10 || + hw->hw_type == rnp_hw_n400) rnp_mbx_force_speed(hw, 0); if (rnp_mbx_get_capability(hw, ii)) { dev_err(&pdev->dev, @@ -7005,7 +6897,6 @@ static int rnp_add_adpater(struct pci_dev *pdev, struct rnp_info *ii, /* carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off(netdev); - if (adapter->flags & RNP_FLAG_SRIOV_ENABLED) { DPRINTK(PROBE, INFO, "IOV is enabled with %d VFs\n", adapter->num_vfs); @@ -7044,7 +6935,7 @@ static int rnp_add_adpater(struct pci_dev *pdev, struct rnp_info *ii, /** * rnp_probe - Device Initialization Routine * @pdev: PCI device information struct - * @ent: entry in rnp_pci_tbl + * @id: pci_device_id * * Returns 0 on success, negative on failure * @@ -7076,42 +6967,39 @@ static int rnp_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (enable_hi_dma) { if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(56)) && - !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(56))) { + !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(56))) { enable_hi_dma = 1; } else { err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (err) { err = dma_set_coherent_mask(&pdev->dev, - DMA_BIT_MASK(32)); + DMA_BIT_MASK(32)); if (err) { dev_err(&pdev->dev, - "No usable DMA configuration, aborting\n"); + "No usable DMA configuration, aborting\n"); goto err_dma; } } enable_hi_dma = 0; } } else { - err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); - if (err) { - err = dma_set_coherent_mask(&pdev->dev, - DMA_BIT_MASK(32)); - if (err) { - dev_err(&pdev->dev, - "No usable DMA configuration, aborting\n"); - goto err_dma; - } + if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) && + !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { + enable_hi_dma = 0; + } else { + dev_err(&pdev->dev, + "No usable DMA configuration, aborting\n"); + goto err_dma; } } err = pci_request_mem_regions(pdev, rnp_driver_name); if (err) { dev_err(&pdev->dev, - "pci_request_selected_regions failed 0x%x\n", err); + "pci_request_selected_regions failed 0x%x\n", err); goto err_pci_reg; } - pci_set_master(pdev); pci_save_state(pdev); @@ -7160,7 +7048,7 @@ static void rnp_remove(struct pci_dev *pdev) * this device has been detected. */ static pci_ers_result_t rnp_io_error_detected(struct pci_dev *pdev, - pci_channel_state_t state) + pci_channel_state_t state) { struct rnp_adapter *adapter = pci_get_drvdata(pdev); struct net_device *netdev = adapter->netdev; @@ -7203,7 +7091,7 @@ static pci_ers_result_t rnp_io_error_detected(struct pci_dev *pdev, vf = (req_id & 0x7F) >> 1; e_dev_err("VF %d has caused a PCIe error\n", vf); e_dev_err("TLP: dw0: %8.8x\tdw1: %8.8x\tdw2:", - dw0, dw1); + dw0, dw1); e_dev_err("%8.8x\tdw3: %8.8x\n", dw2, dw3); switch (hw->hw_type) { case rnp_hw_n10: @@ -7221,10 +7109,9 @@ static pci_ers_result_t rnp_io_error_detected(struct pci_dev *pdev, if (vfdev->devfn == (req_id & 0xFF)) break; vfdev = pci_get_device(PCI_VENDOR_ID_MUCSE, device_id, - vfdev); + vfdev); } - /* - * There's a slim chance the VF could have been hot plugged, + /* There's a slim chance the VF could have been hot plugged, * so if it is no longer present we don't need to issue the * VFLR. Just clean up the AER in that case. */ @@ -7238,8 +7125,7 @@ static pci_ers_result_t rnp_io_error_detected(struct pci_dev *pdev, pci_aer_clear_nonfatal_status(pdev); } - /* - * Even though the error may have occurred on the other port + /* Even though the error may have occurred on the other port * we still need to increment the vf error reference count for * both ports because the I/O resume function will be called * for both of them. @@ -7270,7 +7156,6 @@ static pci_ers_result_t rnp_io_error_detected(struct pci_dev *pdev, */ static pci_ers_result_t rnp_io_slot_reset(struct pci_dev *pdev) { - pci_ers_result_t result = PCI_ERS_RESULT_NONE; struct rnp_adapter *adapter = pci_get_drvdata(pdev); diff --git a/drivers/net/ethernet/mucse/rnp/rnp_mbx.c b/drivers/net/ethernet/mucse/rnp/rnp_mbx.c index 7cba40f3f07a..5247508e445e 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_mbx.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_mbx.c @@ -10,8 +10,6 @@ #include "rnp_mbx.h" #include "rnp_mbx_fw.h" - - /** * rnp_read_mbx - Reads a message from the mailbox * @hw: pointer to the HW structure @@ -268,7 +266,7 @@ static s32 rnp_write_posted_mbx(struct rnp_hw *hw, u32 *msg, u16 size, /** * rnp_check_for_msg_pf - checks to see if the VF has sent mail * @hw: pointer to the HW structure - * @vf_number: the VF index + * @mbx_id: the VF index * * returns SUCCESS if the VF has set the Status bit or else ERR_MBX **/ @@ -281,8 +279,8 @@ static s32 rnp_check_for_msg_pf(struct rnp_hw *hw, enum MBX_ID mbx_id) if (mbx_id == MBX_CM3CPU) { hw_req_count = rnp_mbx_get_req(hw, CPU2PF_COUNTER(mbx)); if (mbx->mbx_feature & MBX_FEATURE_NO_ZERO) { - if ((hw_req_count != 0) && - (hw_req_count != hw->mbx.cpu_req)) { + if (hw_req_count != 0 && + hw_req_count != hw->mbx.cpu_req) { ret_val = 0; hw->mbx.stats.reqs++; } @@ -306,7 +304,7 @@ static s32 rnp_check_for_msg_pf(struct rnp_hw *hw, enum MBX_ID mbx_id) /** * rnp_check_for_ack_pf - checks to see if the VF has ACKed * @hw: pointer to the HW structure - * @vf_number: the VF index + * @mbx_id: the VF index * * returns SUCCESS if the VF has set the Status bit or else ERR_MBX **/ @@ -350,7 +348,7 @@ static s32 rnp_obtain_mbx_lock_pf(struct rnp_hw *hw, enum MBX_ID mbx_id) while (try_cnt-- > 0) { /* Take ownership of the buffer */ mbx_wr32(hw, CTRL_REG, MBOX_CTRL_PF_HOLD_SHM); - /* we need this sync memroy */ + /* we need this sync memory */ wmb(); /* reserve mailbox for cm3 use */ if (mbx_rd32(hw, CTRL_REG) & MBOX_CTRL_PF_HOLD_SHM) @@ -386,7 +384,7 @@ static s32 rnp_write_mbx_pf(struct rnp_hw *hw, u32 *msg, u16 size, if (size > RNP_VFMAILBOX_SIZE) { rnp_err("%s: size:%d should <%d\n", __func__, size, - RNP_VFMAILBOX_SIZE); + RNP_VFMAILBOX_SIZE); return -EINVAL; } @@ -394,7 +392,7 @@ static s32 rnp_write_mbx_pf(struct rnp_hw *hw, u32 *msg, u16 size, ret_val = rnp_obtain_mbx_lock_pf(hw, mbx_id); if (ret_val) { rnp_err("%s: get mbx:%d wlock failed. ret:%d. req:0x%08x-0x%08x\n", - __func__, mbx_id, ret_val, msg[0], msg[1]); + __func__, mbx_id, ret_val, msg[0], msg[1]); goto out_no_write; } @@ -430,7 +428,7 @@ static s32 rnp_write_mbx_pf(struct rnp_hw *hw, u32 *msg, u16 size, * @hw: pointer to the HW structure * @msg: The message buffer * @size: Length of buffer - * @vf_number: the VF index + * @mbx_id: the VF index * * This function copies a message from the mailbox buffer to the caller's * memory buffer. The presumption is that the caller knows that there was @@ -449,7 +447,7 @@ static s32 rnp_read_mbx_pf(struct rnp_hw *hw, u32 *msg, u16 size, PF2VF_MBOX_CTRL(mbx, mbx_id); if (size > RNP_VFMAILBOX_SIZE) { rnp_err("%s: size:%d should <%d\n", __func__, size, - RNP_VFMAILBOX_SIZE); + RNP_VFMAILBOX_SIZE); return -EINVAL; } /* lock the mailbox to prevent pf/vf race condition */ @@ -457,7 +455,7 @@ static s32 rnp_read_mbx_pf(struct rnp_hw *hw, u32 *msg, u16 size, if (ret_val) goto out_no_read; - /* force memory sync befor read from mbx */ + /* force memory sync before read from mbx */ mb(); /* copy the message from the mailbox memory buffer */ for (i = 0; i < size; i++) { diff --git a/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.c b/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.c index b389fdc93a00..2c2c16e3619d 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.c @@ -15,7 +15,7 @@ static struct mbx_req_cookie *mbx_cookie_zalloc(int priv_len) { struct mbx_req_cookie *cookie = - kzalloc(sizeof(*cookie) + priv_len, GFP_KERNEL); + kzalloc(struct_size(cookie, priv, priv_len), GFP_KERNEL); if (cookie) { cookie->timeout_jiffes = 30 * HZ; @@ -27,7 +27,7 @@ static struct mbx_req_cookie *mbx_cookie_zalloc(int priv_len) } static int rnp_mbx_write_posted_locked(struct rnp_hw *hw, - struct mbx_fw_cmd_req *req) + struct mbx_fw_cmd_req *req) { int err = 0; int retry = 3; @@ -50,16 +50,18 @@ static int rnp_mbx_write_posted_locked(struct rnp_hw *hw, return -EIO; } - err = hw->mbx.ops.write_posted( - hw, (u32 *)req, (req->datalen + MBX_REQ_HDR_LEN) / 4, - MBX_FW); + err = hw->mbx.ops.write_posted(hw, + (u32 *)req, + (req->datalen + MBX_REQ_HDR_LEN) / 4, + MBX_FW); if (err) goto try_again; mutex_unlock(&hw->mbx.lock); return err; } -/* + +/** * force firmware report link event to driver */ static void rnp_link_stat_mark_reset(struct rnp_hw *hw) @@ -73,7 +75,7 @@ static void rnp_link_stat_mark_disable(struct rnp_hw *hw) } static int rnp_mbx_fw_post_req(struct rnp_hw *hw, struct mbx_fw_cmd_req *req, - struct mbx_req_cookie *cookie) + struct mbx_req_cookie *cookie) { int err = 0; struct rnp_adapter *adpt = hw->back; @@ -102,9 +104,9 @@ static int rnp_mbx_fw_post_req(struct rnp_hw *hw, struct mbx_fw_cmd_req *req, if (cookie->timeout_jiffes != 0) { retry: - err = wait_event_interruptible_timeout( - cookie->wait, cookie->done == 1, - cookie->timeout_jiffes); + err = wait_event_interruptible_timeout(cookie->wait, + cookie->done == 1, + cookie->timeout_jiffes); if (err == -ERESTARTSYS) goto retry; @@ -130,7 +132,7 @@ static int rnp_mbx_fw_post_req(struct rnp_hw *hw, struct mbx_fw_cmd_req *req, } static int rnp_fw_send_cmd_wait(struct rnp_hw *hw, struct mbx_fw_cmd_req *req, - struct mbx_fw_cmd_reply *reply) + struct mbx_fw_cmd_reply *reply) { int err; int retry_cnt = 3; @@ -148,9 +150,10 @@ static int rnp_fw_send_cmd_wait(struct rnp_hw *hw, struct mbx_fw_cmd_req *req, rnp_logd(LOG_MBX_LOCK, "%s %d lock:%p hw:%p opcode:0x%x\n", __func__, hw->pfvfnum, &hw->mbx.lock, hw, req->opcode); - err = hw->mbx.ops.write_posted( - hw, (u32 *)req, (req->datalen + MBX_REQ_HDR_LEN) / 4, - MBX_FW); + err = hw->mbx.ops.write_posted(hw, + (u32 *)req, + (req->datalen + MBX_REQ_HDR_LEN) / 4, + MBX_FW); if (err) { rnp_err("%s: write_posted failed! err:0x%x opcode:0x%x\n", __func__, err, req->opcode); @@ -239,11 +242,12 @@ int rnp_mbx_get_lane_stat(struct rnp_hw *hw) rnp_err("%s: 1 error:%d\n", __func__, err); goto quit; } - st = (struct lane_stat_data *)&(reply.data); + st = (struct lane_stat_data *)&reply.data; } hw->phy_type = st->phy_type; - hw->speed = adpt->speed = st->speed; + adpt->speed = st->speed; + hw->speed = adpt->speed; if (st->is_sgmii) { adpt->phy_addr = st->phy_addr; } else { @@ -268,7 +272,7 @@ int rnp_mbx_get_lane_stat(struct rnp_hw *hw) hw->advertised_link = st->advertised_link; hw->tp_mdx = st->tp_mdx; - if ((hw->hw_type == rnp_hw_n10) || (hw->hw_type == rnp_hw_n400)) { + if (hw->hw_type == rnp_hw_n10 || hw->hw_type == rnp_hw_n400) { if (hw->fw_version >= 0x00050000) { hw->sfp_connector = st->sfp_connector; hw->duplex = st->duplex; @@ -285,15 +289,15 @@ int rnp_mbx_get_lane_stat(struct rnp_hw *hw) } rnp_logd(LOG_MBX_LINK_STAT, - "%s:pma_type:0x%x phy_type:0x%x,linkup:%d duplex:%d auton:%d ", - adpt->name, st->pma_type, st->phy_type, st->linkup, - st->duplex, st->autoneg); + "%s:pma_type:0x%x phy_type:0x%x,linkup:%d duplex:%d auton:%d ", + adpt->name, st->pma_type, st->phy_type, st->linkup, + st->duplex, st->autoneg); rnp_logd(LOG_MBX_LINK_STAT, - "fec:%d an:%d lt:%d is_sgmii:%d supported_link:0x%x, backplane:%d ", - st->fec, st->an, st->link_traing, - st->is_sgmii, hw->supported_link, hw->is_backplane); + "fec:%d an:%d lt:%d is_sgmii:%d supported_link:0x%x, backplane:%d ", + st->fec, st->an, st->link_traing, + st->is_sgmii, hw->supported_link, hw->is_backplane); rnp_logd(LOG_MBX_LINK_STAT, "speed:%d sfp_connector:0x%x\n", - st->speed, st->sfp_connector); + st->speed, st->sfp_connector); quit: kfree(cookie); return err; @@ -366,8 +370,8 @@ int rnp_maintain_req(struct rnp_hw *hw, int cmd, int arg0, memset(&reply, 0, sizeof(reply)); cookie->timeout_jiffes = 60 * HZ; build_maintain_req(&req, cookie, cmd, arg0, req_data_bytes, - reply_bytes, address & 0xffffffff, - (address >> 32) & 0xffffffff); + reply_bytes, address & 0xffffffff, + (address >> 32) & 0xffffffff); if (hw->mbx.other_irq_enabled) { cookie->timeout_jiffes = 400 * HZ; @@ -432,7 +436,7 @@ int rnp_fw_get_macaddr(struct rnp_hw *hw, int pfvfnum, u8 *mac_addr, } build_get_macaddress_req(&req, 1 << nr_lane, pfvfnum, - &req); + &req); err = rnp_fw_send_cmd_wait(hw, &req, &reply); if (err) { rnp_err("%s: failed. err:%d\n", __func__, err); @@ -448,13 +452,13 @@ int rnp_fw_get_macaddr(struct rnp_hw *hw, int pfvfnum, u8 *mac_addr, } static int rnp_mbx_sfp_read(struct rnp_hw *hw, int sfp_i2c_addr, int reg, - int cnt, u8 *out_buf) + int cnt, u8 *out_buf) { struct mbx_fw_cmd_req req; int err = -EIO; int nr_lane = hw->nr_lane; - if ((cnt > MBX_SFP_READ_MAX_CNT) || !out_buf) { + if (cnt > MBX_SFP_READ_MAX_CNT || !out_buf) { rnp_err("%s: cnt:%d should <= %d out_buf:%p\n", __func__, cnt, MBX_SFP_READ_MAX_CNT, out_buf); return -EINVAL; @@ -466,7 +470,7 @@ static int rnp_mbx_sfp_read(struct rnp_hw *hw, int sfp_i2c_addr, int reg, if (!cookie) return -ENOMEM; build_mbx_sfp_read(&req, nr_lane, sfp_i2c_addr, reg, cnt, - cookie); + cookie); err = rnp_mbx_fw_post_req(hw, &req, cookie); if (err) { kfree(cookie); @@ -480,7 +484,7 @@ static int rnp_mbx_sfp_read(struct rnp_hw *hw, int sfp_i2c_addr, int reg, memset(&reply, 0, sizeof(reply)); build_mbx_sfp_read(&req, nr_lane, sfp_i2c_addr, reg, cnt, - &reply); + &reply); err = rnp_fw_send_cmd_wait(hw, &req, &reply); if (err == 0) memcpy(out_buf, reply.sfp_read.value, cnt); @@ -718,7 +722,7 @@ int rnp_mbx_get_dump(struct rnp_hw *hw, int flags, u8 *data_out, int bytes) memset(&reply, 0, sizeof(reply)); if (bytes > sizeof(get_dump->data)) { dma_buf = dma_alloc_coherent(&hw->pdev->dev, bytes, - &dma_phy, GFP_ATOMIC); + &dma_phy, GFP_ATOMIC); if (!dma_buf) { err = -ENOMEM; goto quit; @@ -727,7 +731,7 @@ int rnp_mbx_get_dump(struct rnp_hw *hw, int flags, u8 *data_out, int bytes) address = dma_phy; build_get_dump_req(&req, cookie, hw->nr_lane, address & 0xffffffff, - (address >> 32) & 0xffffffff, bytes); + (address >> 32) & 0xffffffff, bytes); if (hw->mbx.other_irq_enabled) { err = rnp_mbx_fw_post_req(hw, &req, cookie); @@ -783,7 +787,7 @@ int rnp_fw_update(struct rnp_hw *hw, int partition, const u8 *fw_bin, memset(&req, 0, sizeof(req)); memset(&reply, 0, sizeof(reply)); dma_buf = dma_alloc_coherent(&hw->pdev->dev, bytes, &dma_phy, - GFP_ATOMIC); + GFP_ATOMIC); if (!dma_buf) { err = -ENOMEM; goto quit; @@ -791,7 +795,7 @@ int rnp_fw_update(struct rnp_hw *hw, int partition, const u8 *fw_bin, memcpy(dma_buf, fw_bin, bytes); address = dma_phy; build_fw_update_req(&req, cookie, partition, address & 0xffffffff, - (address >> 32) & 0xffffffff, bytes); + (address >> 32) & 0xffffffff, bytes); if (hw->mbx.other_irq_enabled) { cookie->timeout_jiffes = 400 * HZ; err = rnp_mbx_fw_post_req(hw, &req, cookie); @@ -813,7 +817,7 @@ int rnp_fw_update(struct rnp_hw *hw, int partition, const u8 *fw_bin, } /** - * rnp_mbx_link_event_eanble - set link event status to firmware + * rnp_mbx_link_event_enable - set link event status to firmware * @hw: hw private structure * @enable: status * @@ -837,7 +841,7 @@ int rnp_mbx_link_event_enable(struct rnp_hw *hw, int enable) wr32(hw, RNP_DMA_DUMY, 0); } build_link_set_event_mask(&req, BIT(EVT_LINK_UP), - (enable & 1) << EVT_LINK_UP, &req); + (enable & 1) << EVT_LINK_UP, &req); err = rnp_mbx_write_posted_locked(hw, &req); return err; @@ -863,18 +867,18 @@ static int to_mac_type(struct phy_abilities *ability) { int lanes = hweight_long(ability->lane_mask); - if ((ability->phy_type == PHY_TYPE_40G_BASE_KR4) || - (ability->phy_type == PHY_TYPE_40G_BASE_LR4) || - (ability->phy_type == PHY_TYPE_40G_BASE_CR4) || - (ability->phy_type == PHY_TYPE_40G_BASE_SR4)) { + if (ability->phy_type == PHY_TYPE_40G_BASE_KR4 || + ability->phy_type == PHY_TYPE_40G_BASE_LR4 || + ability->phy_type == PHY_TYPE_40G_BASE_CR4 || + ability->phy_type == PHY_TYPE_40G_BASE_SR4) { if (lanes == 1) return rnp_mac_n10g_x8_40G; else return rnp_mac_n10g_x8_10G; - } else if ((ability->phy_type == PHY_TYPE_10G_BASE_KR) || - (ability->phy_type == PHY_TYPE_10G_BASE_LR) || - (ability->phy_type == PHY_TYPE_10G_BASE_ER) || - (ability->phy_type == PHY_TYPE_10G_BASE_SR)) { + } else if (ability->phy_type == PHY_TYPE_10G_BASE_KR || + ability->phy_type == PHY_TYPE_10G_BASE_LR || + ability->phy_type == PHY_TYPE_10G_BASE_ER || + ability->phy_type == PHY_TYPE_10G_BASE_SR) { if (lanes == 1) return rnp_mac_n10g_x2_10G; else if (lanes == 2) @@ -894,7 +898,10 @@ static int to_mac_type(struct phy_abilities *ability) * rnp_set_lane_fun - set lane value * @hw: hw private structure * @fun: fun id - * @vlaue0, vlaue1, value2, vlaue3: values + * @value0: values + * @value1: values + * @value2: values + * @value3: values * **/ int rnp_set_lane_fun(struct rnp_hw *hw, int fun, int value0, int value1, @@ -906,7 +913,7 @@ int rnp_set_lane_fun(struct rnp_hw *hw, int fun, int value0, int value1, memset(&req, 0, sizeof(req)); memset(&reply, 0, sizeof(reply)); build_set_lane_fun(&req, hw->nr_lane, fun, value0, value1, value2, - value3); + value3); return rnp_mbx_write_posted_locked(hw, &req); } @@ -1017,7 +1024,7 @@ int rnp_mbx_led_set(struct rnp_hw *hw, int value) /** * rnp_mbx_get_capability - get hw capability * @hw: hw private structure - * @rnp_info: rnp_info structure + * @info: rnp_info structure * **/ int rnp_mbx_get_capability(struct rnp_hw *hw, struct rnp_info *info) @@ -1049,8 +1056,8 @@ int rnp_mbx_get_capability(struct rnp_hw *hw, struct rnp_info *info) hw->wol = ablity.wol_status; hw->eco = ablity.e.v2; - if ((hw->fw_version >= 0x00050201) && - (ablity.speed == SPEED_10000)) { + if (hw->fw_version >= 0x00050201 && + ablity.speed == SPEED_10000) { hw->force_speed_stat = FORCE_SPEED_STAT_DISABLED; hw->force_10g_1g_speed_ablity = 1; @@ -1070,20 +1077,20 @@ int rnp_mbx_get_capability(struct rnp_hw *hw, struct rnp_info *info) } pr_info("%s: nic-mode:%d mac:%d adpt_cnt:%d lane_mask:0x%x", - __func__, hw->mode, info->mac, - info->adapter_cnt, hw->lane_mask); + __func__, hw->mode, info->mac, + info->adapter_cnt, hw->lane_mask); pr_info("phy_type 0x%x, pfvfnum:0x%x, fw-version:0x%08x\n, axi:%d Mhz,", - hw->phy_type, hw->pfvfnum, - ablity.fw_version, ablity.axi_mhz); + hw->phy_type, hw->pfvfnum, + ablity.fw_version, ablity.axi_mhz); pr_info("port_id:%d bd_uid:0x%08x 0x%x ex-ablity:0x%x fs:%d speed:%d ", - ablity.port_id[0], hw->bd_uid, - ablity.phy_id, ablity.ext_ablity, - hw->force_10g_1g_speed_ablity, - ablity.speed); + ablity.port_id[0], hw->bd_uid, + ablity.phy_id, ablity.ext_ablity, + hw->force_10g_1g_speed_ablity, + ablity.speed); pr_info("ncsi_en:%u %d wol=0x%x rpu:%d-%d eco %d\n", - hw->ncsi_en, - hw->ncsi_rar_entries, hw->wol, hw->rpu_en, - hw->rpu_availble, hw->eco); + hw->ncsi_en, + hw->ncsi_rar_entries, hw->wol, hw->rpu_en, + hw->rpu_availble, hw->eco); if (info->adapter_cnt != 0) return 0; @@ -1102,7 +1109,6 @@ int rnp_mbx_get_capability(struct rnp_hw *hw, struct rnp_info *info) **/ int rnp_mbx_get_temp(struct rnp_hw *hw, int *voltage) { - int err; struct mbx_req_cookie *cookie = NULL; struct mbx_fw_cmd_reply reply; struct mbx_fw_cmd_req req; @@ -1116,10 +1122,10 @@ int rnp_mbx_get_temp(struct rnp_hw *hw, int *voltage) memset(&req, 0, sizeof(req)); build_get_temp(&req, cookie); if (hw->mbx.other_irq_enabled) { - err = rnp_mbx_fw_post_req(hw, &req, cookie); + rnp_mbx_fw_post_req(hw, &req, cookie); } else { memset(&reply, 0, sizeof(reply)); - err = rnp_fw_send_cmd_wait(hw, &req, &reply); + rnp_fw_send_cmd_wait(hw, &req, &reply); temp = &reply.get_temp; } if (voltage) @@ -1131,30 +1137,6 @@ int rnp_mbx_get_temp(struct rnp_hw *hw, int *voltage) return temp_v; } -/** - * rnp_fw_reg_read - read a fw register - * @hw: hw private structure - * @addr: register start offset - * @sz: register number - * - **/ -int rnp_fw_reg_read(struct rnp_hw *hw, int addr, int sz) -{ - struct mbx_req_cookie *cookie; - struct mbx_fw_cmd_req req; - int value; - - cookie = mbx_cookie_zalloc(sizeof(int)); - if (!cookie) - return -ENOMEM; - build_readreg_req(&req, addr, cookie); - rnp_mbx_fw_post_req(hw, &req, cookie); - value = *((int *)cookie->priv); - kfree(cookie); - - return 0; -} - enum speed_enum { speed_10, speed_100, @@ -1166,7 +1148,7 @@ enum speed_enum { }; /** - * rnp_mbx_stat_mark - write back link stat to firmware + * rnp_link_stat_mark - write back link stat to firmware * @hw: hw private structure * @up: link status * @@ -1176,7 +1158,7 @@ void rnp_link_stat_mark(struct rnp_hw *hw, int up) u32 v; v = rd32(hw, RNP_DMA_DUMY); - if ((hw->hw_type == rnp_hw_n10) || (hw->hw_type == rnp_hw_n400)) { + if (hw->hw_type == rnp_hw_n10 || hw->hw_type == rnp_hw_n400) { v &= ~(0xffff0000); v |= 0xa5a40000; if (up) @@ -1199,7 +1181,7 @@ void rnp_mbx_probe_stat_set(struct rnp_hw *hw, int stat) u32 v; v = rd32(hw, RNP_DMA_DUMY); - if ((hw->hw_type == rnp_hw_n10) || (hw->hw_type == rnp_hw_n400)) { + if (hw->hw_type == rnp_hw_n10 || hw->hw_type == rnp_hw_n400) { v &= ~(0xffff0000); v |= 0xa5a40000; if (stat == MBX_PROBE) @@ -1220,14 +1202,14 @@ static inline int rnp_mbx_fw_req_handler(struct rnp_adapter *adapter, switch (req->opcode) { case LINK_STATUS_EVENT: rnp_logd(LOG_LINK_EVENT, - "[LINK_STATUS_EVENT:0x%x] %s:link changed: changed_lane:0x%x\n", - req->opcode, adapter->name, - req->link_stat.changed_lanes); + "[LINK_STATUS_EVENT:0x%x] %s:link changed: changed_lane:0x%x\n", + req->opcode, adapter->name, + req->link_stat.changed_lanes); rnp_logd(LOG_LINK_EVENT, - "status:0x%x, speed:%d, duplex:%d\n", - req->link_stat.lane_status, - req->link_stat.st[0].speed, - req->link_stat.st[0].duplex); + "status:0x%x, speed:%d, duplex:%d\n", + req->link_stat.lane_status, + req->link_stat.st[0].speed, + req->link_stat.st[0].duplex); if (req->link_stat.lane_status) adapter->hw.link = 1; @@ -1302,15 +1284,15 @@ static inline int rnp_rcv_msg_from_fw(struct rnp_adapter *adapter) if (retval) return retval; rnp_logd(LOG_MBX_MSG_IN, - "msg from fw: msg[0]=0x%08x_0x%08x_0x%08x_0x%08x\n", - msgbuf[0], msgbuf[1], msgbuf[2], msgbuf[3]); + "msg from fw: msg[0]=0x%08x_0x%08x_0x%08x_0x%08x\n", + msgbuf[0], msgbuf[1], msgbuf[2], msgbuf[3]); if (((unsigned short *)msgbuf)[0] & FLAGS_DD) { - return rnp_mbx_fw_reply_handler( - adapter, (struct mbx_fw_cmd_reply *)msgbuf); + return rnp_mbx_fw_reply_handler(adapter, + (struct mbx_fw_cmd_reply *)msgbuf); } else { - return rnp_mbx_fw_req_handler( - adapter, (struct mbx_fw_cmd_req *)msgbuf); + return rnp_mbx_fw_req_handler(adapter, + (struct mbx_fw_cmd_req *)msgbuf); } } @@ -1376,7 +1358,7 @@ int rnp_mbx_phy_read(struct rnp_hw *hw, u32 reg, u32 *val) if (!cookie) return -ENOMEM; build_get_phy_reg(&req, cookie, PHY_EXTERNAL_PHY_MDIO, - nr_lane, reg); + nr_lane, reg); err = rnp_mbx_fw_post_req(hw, &req, cookie); if (err) { @@ -1391,7 +1373,7 @@ int rnp_mbx_phy_read(struct rnp_hw *hw, u32 reg, u32 *val) memset(&reply, 0, sizeof(reply)); build_get_phy_reg(&req, &reply, PHY_EXTERNAL_PHY_MDIO, - nr_lane, reg); + nr_lane, reg); err = rnp_fw_send_cmd_wait(hw, &req, &reply); if (err == 0) @@ -1403,6 +1385,7 @@ int rnp_mbx_phy_read(struct rnp_hw *hw, u32 reg, u32 *val) /** * rnp_mbx_phy_link_set - set phy link statues * @hw: hw private structure + * @adv: advertised_link * @autoneg: neg status * @speed: speed * @duplex: duplex status @@ -1417,7 +1400,7 @@ int rnp_mbx_phy_link_set(struct rnp_hw *hw, int adv, int autoneg, memset(&req, 0, sizeof(req)); build_phy_link_set(&req, adv, hw->nr_lane, autoneg, speed, duplex, - mdix_ctrl); + mdix_ctrl); if (mutex_lock_interruptible(&hw->mbx.lock)) return -EAGAIN; @@ -1453,22 +1436,6 @@ int rnp_mbx_phy_pause_set(struct rnp_hw *hw, int pause_mode) return err; } -int rnp_mbx_lldp_all_ports_enable(struct rnp_hw *hw, bool enable) -{ - struct mbx_fw_cmd_req req; - int err; - - if (!hw->fw_lldp_ablity) - return -EOPNOTSUPP; - - memset(&req, 0, sizeof(req)); - - build_lldp_ctrl_set(&req, LLDP_TX_ALL_LANES, enable); - - err = rnp_mbx_write_posted_locked(hw, &req); - return err; -} - int rnp_mbx_lldp_port_enable(struct rnp_hw *hw, bool enable) { struct mbx_fw_cmd_req req; diff --git a/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h b/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h index 9ce9aaa18038..5ded24d618cc 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h +++ b/drivers/net/ethernet/mucse/rnp/rnp_mbx_fw.h @@ -12,31 +12,31 @@ #define _PACKED_ALIGN4 __attribute__((packed, aligned(4))) #endif -#define VF2PF_MBOX_VEC(mbx, vf) (mbx->vf2pf_mbox_vec_base + 4 * (vf)) -#define CPU2PF_MBOX_VEC(mbx) (mbx->cpu2pf_mbox_vec) +#define VF2PF_MBOX_VEC(mbx, vf) ((mbx)->vf2pf_mbox_vec_base + 4 * (vf)) +#define CPU2PF_MBOX_VEC(mbx) ((mbx)->cpu2pf_mbox_vec) /* == PF <--> VF mailbox ==== */ #define SHARE_MEM_BYTES (64) #define PF_VF_SHM(mbx, vf) \ - (mbx->pf_vf_shm_base + \ - mbx->mbx_mem_size * vf) + ((mbx)->pf_vf_shm_base + \ + (mbx)->mbx_mem_size * (vf)) /* for PF1 rtl will remap 6000 to 0xb000 */ #define PF2VF_COUNTER(mbx, vf) (PF_VF_SHM(mbx, vf) + 0) #define VF2PF_COUNTER(mbx, vf) (PF_VF_SHM(mbx, vf) + 4) #define PF_VF_SHM_DATA(mbx, vf) (PF_VF_SHM(mbx, vf) + 8) -#define PF2VF_MBOX_CTRL(mbx, vf) (mbx->pf2vf_mbox_ctrl_base + 4 * vf) -#define PF_VF_MBOX_MASK_LO(mbx) (mbx->pf_vf_mbox_mask_lo) -#define PF_VF_MBOX_MASK_HI(mbx) (mbx->pf_vf_mbox_mask_hi) +#define PF2VF_MBOX_CTRL(mbx, vf) ((mbx)->pf2vf_mbox_ctrl_base + 4 * (vf)) +#define PF_VF_MBOX_MASK_LO(mbx) ((mbx)->pf_vf_mbox_mask_lo) +#define PF_VF_MBOX_MASK_HI(mbx) ((mbx)->pf_vf_mbox_mask_hi) /* === CPU <--> PF === */ -#define CPU_PF_SHM(mbx) (mbx->cpu_pf_shm_base) +#define CPU_PF_SHM(mbx) ((mbx)->cpu_pf_shm_base) #define CPU2PF_COUNTER(mbx) (CPU_PF_SHM(mbx) + 0) #define PF2CPU_COUNTER(mbx) (CPU_PF_SHM(mbx) + 4) #define CPU_PF_SHM_DATA(mbx) (CPU_PF_SHM(mbx) + 8) -#define PF2CPU_MBOX_CTRL(mbx) (mbx->pf2cpu_mbox_ctrl) -#define CPU_PF_MBOX_MASK(mbx) (mbx->cpu_pf_mbox_mask) -#define MBOX_CTRL_REQ (1 << 0) -#define MBOX_CTRL_PF_HOLD_SHM (1 << 3) +#define PF2CPU_MBOX_CTRL(mbx) ((mbx)->pf2cpu_mbox_ctrl) +#define CPU_PF_MBOX_MASK(mbx) ((mbx)->cpu_pf_mbox_mask) +#define MBOX_CTRL_REQ (0x1 << 0) +#define MBOX_CTRL_PF_HOLD_SHM (0x1 << 3) #define MBOX_IRQ_EN 0 #define MBOX_IRQ_DISABLE 1 @@ -57,7 +57,7 @@ struct mbx_req_cookie { wait_queue_head_t wait; int done; int priv_len; - char priv[0]; + char priv[]; }; enum GENERIC_CMD { @@ -182,6 +182,7 @@ enum LOOPBACK_LEVEL { LOOPBACK_PCS = 5, LOOPBACK_EXTERNAL = 6, }; + enum LOOPBACK_TYPE { /* Tx->Rx */ LOOPBACK_TYPE_LOCAL = 0x0, @@ -688,7 +689,6 @@ static inline void build_lldp_ctrl_get(struct mbx_fw_cmd_req *req, req->lldp_tx.nr_lane = nr_lane; } - static inline void build_maintain_req(struct mbx_fw_cmd_req *req, void *cookie, int cmd, int arg0, int req_bytes, int reply_bytes, @@ -863,6 +863,7 @@ static inline void build_get_temp(struct mbx_fw_cmd_req *req, void *cookie) req->reply_lo = 0; req->reply_hi = 0; } + static inline void build_get_dump_req(struct mbx_fw_cmd_req *req, void *cookie, int nr_lane, u32 fw_bin_phy_lo, u32 fw_bin_phy_hi, diff --git a/drivers/net/ethernet/mucse/rnp/rnp_n10.c b/drivers/net/ethernet/mucse/rnp/rnp_n10.c index 2f243ae6ac6a..d5a80c4858a7 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_n10.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_n10.c @@ -44,7 +44,6 @@ #define RNP10_MAX_TCAM_FILTERS 4096 #define RNP10_MAX_TUPLE5_FILTERS 128 - /* setup queue speed limit to max_rate */ static void rnp_dma_set_tx_maxrate_n10(struct rnp_dma_info *dma, u16 queue, u32 max_rate) @@ -119,8 +118,8 @@ static struct rnp_dma_operations dma_ops_n10 = { * * Puts an ethernet address into a receive address register. **/ -s32 rnp_eth_set_rar_n10(struct rnp_eth_info *eth, u32 index, u8 *addr, - bool enable_addr) +static s32 rnp_eth_set_rar_n10(struct rnp_eth_info *eth, u32 index, u8 *addr, + bool enable_addr) { u32 mcstctrl; u32 rar_low, rar_high = 0; @@ -135,16 +134,12 @@ s32 rnp_eth_set_rar_n10(struct rnp_eth_info *eth, u32 index, u8 *addr, eth_dbg(eth, " RAR[%d] <= %pM. vmdq:%d enable:0x%x\n", index, addr); - - - /* - * HW expects these in big endian so we reverse the byte + /* HW expects these in big endian so we reverse the byte * order from network order (big endian) to little endian */ rar_low = ((u32)addr[5] | ((u32)addr[4] << 8) | ((u32)addr[3] << 16) | ((u32)addr[2] << 24)); - /* - * Some parts put the VMDq setting in the extra RAH bits, + /* Some parts put the VMDq setting in the extra RAH bits, * so save everything except the lower 16 bits that hold part * of the address and the address valid bit. */ @@ -176,7 +171,7 @@ s32 rnp_eth_set_rar_n10(struct rnp_eth_info *eth, u32 index, u8 *addr, * * Clears an ethernet address from a receive address register. **/ -s32 rnp_eth_clear_rar_n10(struct rnp_eth_info *eth, u32 index) +static s32 rnp_eth_clear_rar_n10(struct rnp_eth_info *eth, u32 index) { u32 rar_high; u32 rar_entries = eth->num_rar_entries; @@ -187,8 +182,7 @@ s32 rnp_eth_clear_rar_n10(struct rnp_eth_info *eth, u32 index) return RNP_ERR_INVALID_ARGUMENT; } - /* - * Some parts put the VMDq setting in the extra RAH bits, + /* Some parts put the VMDq setting in the extra RAH bits, * so save everything except the lower 16 bits that hold part * of the address and the address valid bit. */ @@ -211,7 +205,7 @@ s32 rnp_eth_clear_rar_n10(struct rnp_eth_info *eth, u32 index) * @vmdq: VMDq pool index * only mac->vf **/ -s32 rnp_eth_set_vmdq_n10(struct rnp_eth_info *eth, u32 rar, u32 vmdq) +static s32 rnp_eth_set_vmdq_n10(struct rnp_eth_info *eth, u32 rar, u32 vmdq) { u32 rar_entries = eth->num_rar_entries; struct rnp_hw *hw = (struct rnp_hw *)ð->back; @@ -241,7 +235,7 @@ s32 rnp_eth_set_vmdq_n10(struct rnp_eth_info *eth, u32 rar, u32 vmdq) * @rar: receive address register index to disassociate * @vmdq: VMDq pool index to remove from the rar **/ -s32 rnp_eth_clear_vmdq_n10(struct rnp_eth_info *eth, u32 rar, u32 vmdq) +static s32 rnp_eth_clear_vmdq_n10(struct rnp_eth_info *eth, u32 rar, u32 vmdq) { u32 rar_entries = eth->num_rar_entries; @@ -294,8 +288,7 @@ static void rnp10_set_mta(struct rnp_hw *hw, u8 *mc_addr) hw->addr_ctrl.mta_in_use++; vector = rnp10_mta_vector(eth, mc_addr); - /* - * The MTA is a register array of 128 32-bit registers. It is treated + /* The MTA is a register array of 128 32-bit registers. It is treated * like an array of 4096 bits. We want to set bit * BitArray[vector_value]. So we figure out what register the bit is * in, read it, OR in the new bit, then write back the new value. The @@ -324,8 +317,7 @@ static void rnp10_set_vf_mta(struct rnp_hw *hw, u16 vector) eth->mta_shadow[vector_reg] |= (1 << vector_bit); } - -u8 *rnp_addr_list_itr(struct rnp_hw __maybe_unused *hw, u8 **mc_addr_ptr) +static u8 *rnp_addr_list_itr(struct rnp_hw __maybe_unused *hw, u8 **mc_addr_ptr) { struct netdev_hw_addr *mc_ptr; u8 *addr = *mc_addr_ptr; @@ -344,7 +336,6 @@ u8 *rnp_addr_list_itr(struct rnp_hw __maybe_unused *hw, u8 **mc_addr_ptr) return addr; } - /** * rnp_eth_update_mc_addr_list_n10 - Updates MAC list of multicast addresses * @eth: pointer to eth structure @@ -356,9 +347,9 @@ u8 *rnp_addr_list_itr(struct rnp_hw __maybe_unused *hw, u8 **mc_addr_ptr) * registers for the first multicast addresses, and hashes the rest into the * multicast table. **/ -s32 rnp_eth_update_mc_addr_list_n10(struct rnp_eth_info *eth, - struct net_device *netdev, - bool sriov_on) +static s32 rnp_eth_update_mc_addr_list_n10(struct rnp_eth_info *eth, + struct net_device *netdev, + bool sriov_on) { struct rnp_hw *hw = (struct rnp_hw *)eth->back; struct netdev_hw_addr *ha; @@ -368,8 +359,7 @@ s32 rnp_eth_update_mc_addr_list_n10(struct rnp_eth_info *eth, u8 *addr_list = NULL; struct rnp_adapter *adapter = (struct rnp_adapter *)hw->back; - /* - * Set the new number of MC addresses that we are being requested to + /* Set the new number of MC addresses that we are being requested to * use. */ hw->addr_ctrl.num_mc_addrs = netdev_mc_count(netdev); @@ -439,7 +429,7 @@ s32 rnp_eth_update_mc_addr_list_n10(struct rnp_eth_info *eth, } /* clean all mc addr */ -void rnp_eth_clr_mc_addr_n10(struct rnp_eth_info *eth) +static void rnp_eth_clr_mc_addr_n10(struct rnp_eth_info *eth) { int i; @@ -450,11 +440,11 @@ void rnp_eth_clr_mc_addr_n10(struct rnp_eth_info *eth) /** * rnp_eth_update_rss_key_n10 - Remove Rx address register * @eth: pointer to eth structure - * @sriov_flag sriov status + * @sriov_flag: sriov status * * update rss key to eth regs **/ -void rnp_eth_update_rss_key_n10(struct rnp_eth_info *eth, bool sriov_flag) +static void rnp_eth_update_rss_key_n10(struct rnp_eth_info *eth, bool sriov_flag) { struct rnp_hw *hw = (struct rnp_hw *)eth->back; int i; @@ -485,7 +475,7 @@ void rnp_eth_update_rss_key_n10(struct rnp_eth_info *eth, bool sriov_flag) * * update rss table to eth regs **/ -void rnp_eth_update_rss_table_n10(struct rnp_eth_info *eth) +static void rnp_eth_update_rss_table_n10(struct rnp_eth_info *eth) { struct rnp_hw *hw = (struct rnp_hw *)eth->back; u32 reta_entries = hw->rss_indir_tbl_num; @@ -510,7 +500,7 @@ void rnp_eth_update_rss_table_n10(struct rnp_eth_info *eth) * * Turn on/off specified VLAN in the VLAN filter table. **/ -s32 rnp_eth_set_vfta_n10(struct rnp_eth_info *eth, u32 vlan, bool vlan_on) +static s32 rnp_eth_set_vfta_n10(struct rnp_eth_info *eth, u32 vlan, bool vlan_on) { s32 regindex; u32 bitindex; @@ -521,8 +511,7 @@ s32 rnp_eth_set_vfta_n10(struct rnp_eth_info *eth, u32 vlan, bool vlan_on) if (vlan > 4095) return RNP_ERR_PARAM; - /* - * The VFTA is a bitstring made up of 128 32-bit registers + /* The VFTA is a bitstring made up of 128 32-bit registers * that enable the particular VLAN id, much like the MTA: * bits[11-5]: which register * bits[4-0]: which bit in the register @@ -550,13 +539,14 @@ s32 rnp_eth_set_vfta_n10(struct rnp_eth_info *eth, u32 vlan, bool vlan_on) return 0; } -void rnp_eth_clr_vfta_n10(struct rnp_eth_info *eth) +static void rnp_eth_clr_vfta_n10(struct rnp_eth_info *eth) { u32 offset; for (offset = 0; offset < eth->vft_size; offset++) eth_wr32(eth, RNP10_VFTA(offset), 0); } + /** * rnp_eth_set_vlan_filter_n10 - Set VLAN filter table * @eth: pointer to eth structure @@ -576,14 +566,14 @@ static void rnp_eth_set_vlan_filter_n10(struct rnp_eth_info *eth, eth_wr32(eth, RNP10_ETH_VLAN_FILTER_ENABLE, value); } -u16 rnp_layer2_pritologic_n10(u16 hw_id) +static u16 rnp_layer2_pritologic_n10(u16 hw_id) { return hw_id; } -void rnp_eth_set_layer2_n10(struct rnp_eth_info *eth, - union rnp_atr_input *input, u16 pri_id, - u8 queue, bool prio_flag) +static void rnp_eth_set_layer2_n10(struct rnp_eth_info *eth, + union rnp_atr_input *input, u16 pri_id, + u8 queue, bool prio_flag) { u16 hw_id; @@ -607,7 +597,7 @@ void rnp_eth_set_layer2_n10(struct rnp_eth_info *eth, } } -void rnp_eth_clr_layer2_n10(struct rnp_eth_info *eth, u16 pri_id) +static void rnp_eth_clr_layer2_n10(struct rnp_eth_info *eth, u16 pri_id) { u16 hw_id; @@ -615,7 +605,7 @@ void rnp_eth_clr_layer2_n10(struct rnp_eth_info *eth, u16 pri_id) eth_wr32(eth, RNP10_ETH_LAYER2_ETQF(hw_id), 0); } -void rnp_eth_clr_all_layer2_n10(struct rnp_eth_info *eth) +static void rnp_eth_clr_all_layer2_n10(struct rnp_eth_info *eth) { int i; #define RNP10_MAX_LAYER2_FILTERS 16 @@ -623,12 +613,12 @@ void rnp_eth_clr_all_layer2_n10(struct rnp_eth_info *eth) eth_wr32(eth, RNP10_ETH_LAYER2_ETQF(i), 0); } -u16 rnp_tuple5_pritologic_n10(u16 hw_id) +static u16 rnp_tuple5_pritologic_n10(u16 hw_id) { return hw_id; } -u16 rnp_tuple5_pritologic_tcam_n10(u16 pri_id) +static u16 rnp_tuple5_pritologic_tcam_n10(u16 pri_id) { int i; int hw_id = 0; @@ -643,9 +633,9 @@ u16 rnp_tuple5_pritologic_tcam_n10(u16 pri_id) return hw_id; } -void rnp_eth_set_tuple5_n10(struct rnp_eth_info *eth, - union rnp_atr_input *input, u16 pri_id, - u8 queue, bool prio_flag) +static void rnp_eth_set_tuple5_n10(struct rnp_eth_info *eth, + union rnp_atr_input *input, u16 pri_id, + u8 queue, bool prio_flag) { struct rnp_hw *hw = (struct rnp_hw *)eth->back; @@ -763,7 +753,6 @@ void rnp_eth_set_tuple5_n10(struct rnp_eth_info *eth, port |= (htons(input->formatted.src_port) << 16); port_mask |= (htons(input->formatted.src_port_mask) << 16); - } if (input->formatted.dst_port != 0) { port |= (htons(input->formatted.dst_port)); @@ -828,7 +817,7 @@ void rnp_eth_set_tuple5_n10(struct rnp_eth_info *eth, } } -void rnp_eth_clr_tuple5_n10(struct rnp_eth_info *eth, u16 pri_id) +static void rnp_eth_clr_tuple5_n10(struct rnp_eth_info *eth, u16 pri_id) { u16 hw_id; struct rnp_hw *hw = (struct rnp_hw *)eth->back; @@ -852,7 +841,7 @@ void rnp_eth_clr_tuple5_n10(struct rnp_eth_info *eth, u16 pri_id) } } -void rnp_eth_clr_all_tuple5_n10(struct rnp_eth_info *eth) +static void rnp_eth_clr_all_tuple5_n10(struct rnp_eth_info *eth) { int i; @@ -885,8 +874,8 @@ void rnp_eth_clr_all_tuple5_n10(struct rnp_eth_info *eth) } } -void rnp_eth_set_tcp_sync_n10(struct rnp_eth_info *eth, int queue, - bool flag, bool prio) +static void rnp_eth_set_tcp_sync_n10(struct rnp_eth_info *eth, int queue, + bool flag, bool prio) { if (flag) { eth_wr32(eth, RNP10_ETH_SYNQF, @@ -910,7 +899,7 @@ static void rnp_eth_set_vlan_strip_n10(struct rnp_eth_info *eth, u16 queue, u32 offset = queue % 32; u32 data = eth_rd32(eth, reg); - if (enable == true) + if (enable) data |= (1 << offset); else data &= ~(1 << offset); @@ -1066,7 +1055,7 @@ static void rnp_ncsi_set_mc_mta_n10(struct rnp_eth_info *eth) mac[4] = ncsi_shm.mc[i].mc_addr_hi & 0xff; mac[5] = (ncsi_shm.mc[i].mc_addr_hi >> 8) & 0xff; if (is_multicast_ether_addr(mac) && - !is_zero_ether_addr(mac)) + !is_zero_ether_addr(mac)) rnp10_set_mta(hw, mac); } } @@ -1122,7 +1111,7 @@ static struct rnp_eth_operations eth_ops_n10 = { }; /** - * rnp_init_hw_n10 - Generic hardware initialization + * rnp_init_hw_ops_n10 - Generic hardware initialization * @hw: pointer to hardware structure * * Initialize the hardware by resetting the hardware, filling the bus info @@ -1131,7 +1120,7 @@ static struct rnp_eth_operations eth_ops_n10 = { * up link and flow control settings, and leaves transmit and receive units * disabled and uninitialized **/ -s32 rnp_init_hw_ops_n10(struct rnp_hw *hw) +static s32 rnp_init_hw_ops_n10(struct rnp_hw *hw) { s32 status = 0; @@ -1145,7 +1134,7 @@ s32 rnp_init_hw_ops_n10(struct rnp_hw *hw) return status; } -s32 rnp_get_permtion_mac_addr_n10(struct rnp_hw *hw, u8 *mac_addr) +static s32 rnp_get_permtion_mac_addr_n10(struct rnp_hw *hw, u8 *mac_addr) { if (rnp_fw_get_macaddr(hw, hw->pfvfnum, mac_addr, hw->nr_lane)) eth_random_addr(mac_addr); @@ -1155,7 +1144,7 @@ s32 rnp_get_permtion_mac_addr_n10(struct rnp_hw *hw, u8 *mac_addr) return 0; } -s32 rnp_reset_hw_ops_n10(struct rnp_hw *hw) +static s32 rnp_reset_hw_ops_n10(struct rnp_hw *hw) { int i; struct rnp_dma_info *dma = &hw->dma; @@ -1166,9 +1155,7 @@ s32 rnp_reset_hw_ops_n10(struct rnp_hw *hw) #define N10_NIC_RESET 0 wr32(hw, RNP10_TOP_NIC_REST_N, N10_NIC_RESET); - /* - * we need this - */ + /* we need this */ wmb(); wr32(hw, RNP10_TOP_NIC_REST_N, ~N10_NIC_RESET); @@ -1217,8 +1204,9 @@ s32 rnp_reset_hw_ops_n10(struct rnp_hw *hw) } else if ((!(hw->fc.requested_mode & PAUSE_TX)) && (!(hw->fc.requested_mode & PAUSE_RX))) { //do nothing - } else + } else { pause_bits |= ASYM_PAUSE | SYM_PAUSE; + } } rnp_mbx_phy_read(hw, 4, &value); value &= ~0xC00; @@ -1229,7 +1217,7 @@ s32 rnp_reset_hw_ops_n10(struct rnp_hw *hw) return 0; } -s32 rnp_start_hw_ops_n10(struct rnp_hw *hw) +static s32 rnp_start_hw_ops_n10(struct rnp_hw *hw) { s32 ret_val = 0; struct rnp_eth_info *eth = &hw->eth; @@ -1354,8 +1342,10 @@ static void rnp_set_mac_hw_ops_n10(struct rnp_hw *hw, u8 *mac, } /** - * rnp_write_uc_addr_list - write unicast addresses to RAR table + * rnp_write_uc_addr_list_n10 - write unicast addresses to RAR table + * @hw: pointer to hardware structure * @netdev: network interface device structure + * @sriov_flag: sriov_flag status * * Writes unicast address list to the RAR table. * Returns: -ENOMEM on failure/insufficient address space @@ -1414,15 +1404,17 @@ static int rnp_write_uc_addr_list_n10(struct rnp_hw *hw, return count; } + static void rnp_set_rx_mode_hw_ops_n10(struct rnp_hw *hw, struct net_device *netdev, bool sriov_flag) { struct rnp_adapter *adapter = netdev_priv(netdev); - u32 fctrl; + u32 fctrl, value; netdev_features_t features = netdev->features; int count; struct rnp_eth_info *eth = &hw->eth; + struct rnp_mac_info *mac = &hw->mac; /* broadcast always bypass */ fctrl = eth_rd32(eth, RNP10_ETH_DMAC_FCTRL) | RNP10_FCTRL_BPE; @@ -1452,8 +1444,7 @@ static void rnp_set_rx_mode_hw_ops_n10(struct rnp_hw *hw, hw->addr_ctrl.user_set_promisc = false; } - /* - * Write addresses to available RAR registers, if there is not + /* Write addresses to available RAR registers, if there is not * sufficient space to store all the addresses then enable * unicast promiscuous mode */ @@ -1466,13 +1457,18 @@ static void rnp_set_rx_mode_hw_ops_n10(struct rnp_hw *hw, else eth->ops.set_vlan_filter(eth, false); - if ((hw->addr_ctrl.user_set_promisc == true) || + value = mac_rd32(mac, RNP10_MAC_RX_CFG); + if (hw->addr_ctrl.user_set_promisc || (adapter->priv_flags & RNP_PRIV_FLAG_REC_HDR_LEN_ERR)) { /* set pkt_len_err and hdr_len_err default to 1 */ eth_wr32(eth, RNP10_ETH_ERR_MASK_VECTOR, INNER_L4_BIT | PKT_LEN_ERR | HDR_LEN_ERR); + /* set mac checksum off */ + mac_wr32(mac, RNP10_MAC_RX_CFG, value & (~RNP_IPC_MASK_XLGMAC)); } else { eth_wr32(eth, RNP10_ETH_ERR_MASK_VECTOR, INNER_L4_BIT); + /* set mac checksum off */ + mac_wr32(mac, RNP10_MAC_RX_CFG, value | RNP_IPC_MASK_XLGMAC); } /* also update mtu */ hw->ops.set_mtu(hw, netdev->mtu); @@ -1565,7 +1561,6 @@ static void rnp_set_sriov_status_hw_ops_n10(struct rnp_hw *hw, bool status) #ifdef NIC_VF_FXIED eth_wr32(eth, RNP10_VM_DMAC_MPSAR_RING(127), RNP_N10_MAX_VF - 1); #endif - } static void rnp_set_sriov_vf_mc_hw_ops_n10(struct rnp_hw *hw, u16 mc_addr) @@ -1583,7 +1578,6 @@ static void rnp_set_sriov_vf_mc_hw_ops_n10(struct rnp_hw *hw, u16 mc_addr) eth_wr32(eth, RNP10_ETH_MULTICAST_HASH_TABLE(vector_reg), mta_reg); } - static void rnp_update_sriov_info_hw_ops_n10(struct rnp_hw *hw) { /* update sriov info to hw */ @@ -1663,7 +1657,6 @@ static void rnp_get_pause_mode_hw_ops_n10(struct rnp_hw *hw) } } - static void rnp_update_hw_info_hw_ops_n10(struct rnp_hw *hw) { struct rnp_dma_info *dma = &hw->dma; @@ -1740,8 +1733,7 @@ static s32 rnp_init_rx_addrs_hw_ops_n10(struct rnp_hw *hw) hw_dbg(hw, "init_rx_addrs:rar_entries:%d, mac.addr:%pM\n", rar_entries, hw->mac.addr); - /* - * If the current mac address is valid, assume it is a software override + /* If the current mac address is valid, assume it is a software override * to the permanent address. * Otherwise, use the permanent address from the eeprom. */ @@ -1848,9 +1840,9 @@ static void rnp_set_mbx_ifup_hw_ops_n10(struct rnp_hw *hw, int enable) * * Reads the links register to determine if link is up and the current speed **/ -s32 rnp_check_mac_link_hw_ops_n10(struct rnp_hw *hw, rnp_link_speed *speed, - bool *link_up, bool *duplex, - bool link_up_wait_to_complete) +static s32 rnp_check_mac_link_hw_ops_n10(struct rnp_hw *hw, rnp_link_speed *speed, + bool *link_up, bool *duplex, + bool link_up_wait_to_complete) { if (hw->speed == 10) *speed = RNP_LINK_SPEED_10_FULL; @@ -1873,8 +1865,8 @@ s32 rnp_check_mac_link_hw_ops_n10(struct rnp_hw *hw, rnp_link_speed *speed, return 0; } -s32 rnp_setup_mac_link_hw_ops_n10(struct rnp_hw *hw, u32 adv, u32 autoneg, - u32 speed, u32 duplex) +static s32 rnp_setup_mac_link_hw_ops_n10(struct rnp_hw *hw, u32 adv, u32 autoneg, + u32 speed, u32 duplex) { struct rnp_adapter *adpt = hw->back; u32 value = 0; @@ -1882,12 +1874,12 @@ s32 rnp_setup_mac_link_hw_ops_n10(struct rnp_hw *hw, u32 adv, u32 autoneg, u32 value_r9 = 0; rnp_logd(LOG_PHY, - "%s setup phy: phy_addr=%d speed=%d", - __func__, adpt->phy_addr, speed); + "%s setup phy: phy_addr=%d speed=%d", + __func__, adpt->phy_addr, speed); rnp_logd(LOG_PHY, "duplex=%d autoneg=%d", - duplex, autoneg); + duplex, autoneg); rnp_logd(LOG_PHY, "is_backplane=%d is_sgmii=%d\n", - hw->is_backplane, hw->is_sgmii); + hw->is_backplane, hw->is_sgmii); /* Backplane type, support AN, unsupport set speed */ if (hw->is_backplane) return rnp_set_lane_fun(hw, LANE_FUN_AN, autoneg, 0, 0, 0); @@ -1916,8 +1908,7 @@ s32 rnp_setup_mac_link_hw_ops_n10(struct rnp_hw *hw, u32 adv, u32 autoneg, } rnp_mbx_phy_write(hw, RNP_YT8531_PHY_SPEC_CTRL, value); - /* - * Clear autoneg_advertised and set new values based on input link + /* Clear autoneg_advertised and set new values based on input link * speed. */ hw->phy.autoneg_advertised = speed; @@ -2016,7 +2007,7 @@ s32 rnp_setup_mac_link_hw_ops_n10(struct rnp_hw *hw, u32 adv, u32 autoneg, return 0; } -void rnp_clean_link_hw_ops_n10(struct rnp_hw *hw) +static void rnp_clean_link_hw_ops_n10(struct rnp_hw *hw) { hw->link = 0; } @@ -2111,6 +2102,8 @@ rnp_update_hw_status_hw_ops_n10(struct rnp_hw *hw, net_stats->rx_crc_errors = 0; net_stats->rx_errors = 0; + hw_stats->mac_rx_csum_err = 0; + for (port = 0; port < 4; port++) { /* we use Hardware stats? */ net_stats->rx_crc_errors += @@ -2124,6 +2117,9 @@ rnp_update_hw_status_hw_ops_n10(struct rnp_hw *hw, eth_rd32(eth, RNP10_RXTRANS_GLEN_ERR_PKTS(port)) + eth_rd32(eth, RNP10_RXTRANS_IPH_ERR_PKTS(port)) + eth_rd32(eth, RNP10_RXTRANS_LEN_ERR_PKTS(port)); + + hw_stats->mac_rx_csum_err += + eth_rd32(eth, RNP10_RXTRANS_CSUM_ERR_PKTS(port)); } /* === drop === */ hw_stats->invalid_dropped_packets = @@ -2160,7 +2156,6 @@ rnp_update_hw_status_hw_ops_n10(struct rnp_hw *hw, ((u64)mac_rd32(mac, RNP10_MAC_STATS_MULTICAST_HIGH) << 32); } - enum n10_priv_bits { n10_mac_loopback = 0, n10_switch_loopback = 1, @@ -2192,7 +2187,6 @@ static const char rnp10_priv_flags_strings[][ETH_GSTRING_LEN] = { #define RNP10_PRIV_FLAGS_STR_LEN ARRAY_SIZE(rnp10_priv_flags_strings) - const struct rnp_stats rnp10_gstrings_net_stats[] = { RNP_NETDEV_STAT(rx_packets), RNP_NETDEV_STAT(tx_packets), @@ -2283,7 +2277,6 @@ static int rnp10_get_regs_len(struct net_device *netdev) #define SUPPORTED_10000baseT 0 - static int rnp_set_autoneg_adv_from_hw(struct rnp_hw *hw, struct ethtool_link_ksettings *ks) { @@ -2299,28 +2292,28 @@ static int rnp_set_autoneg_adv_from_hw(struct rnp_hw *hw, rnp_mbx_phy_read(hw, 0x4, &value_r4); rnp_mbx_phy_read(hw, 0x9, &value_r9); if (value_r4 & 0x100) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 100baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 100baseT_Full); } if (value_r4 & 0x80) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 100baseT_Half); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 100baseT_Half); } if (value_r4 & 0x40) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10baseT_Full); } if (value_r4 & 0x20) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10baseT_Half); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10baseT_Half); } if (value_r9 & 0x200) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseT_Full); } if (value_r9 & 0x100) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseT_Half); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseT_Half); } } @@ -2345,43 +2338,43 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, if (phy_type == PHY_TYPE_NONE) { if (supported_link & RNP_LINK_SPEED_10GB_FULL) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseT_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseT_Full); - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseSR_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseSR_Full); - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseLR_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseLR_Full); - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseER_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseER_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseSR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseSR_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseLR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseLR_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseER_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseER_Full); } if (((supported_link & RNP_LINK_SPEED_10GB_FULL) || (supported_link & RNP_LINK_SPEED_1GB_FULL))) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 1000baseX_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseX_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 1000baseX_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseX_Full); } } if (phy_type == PHY_TYPE_SGMII) { ethtool_link_ksettings_add_link_mode(ks, supported, - 1000baseT_Full); + 1000baseT_Full); ethtool_link_ksettings_add_link_mode(ks, supported, - 100baseT_Full); + 100baseT_Full); ethtool_link_ksettings_add_link_mode(ks, supported, - 10baseT_Full); + 10baseT_Full); ethtool_link_ksettings_add_link_mode(ks, supported, - 100baseT_Half); + 100baseT_Half); ethtool_link_ksettings_add_link_mode(ks, supported, - 10baseT_Half); + 10baseT_Half); rnp_set_autoneg_adv_from_hw(hw, ks); } @@ -2395,21 +2388,21 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, if (supported_link & RNP_SFP_MODE_40G_CR4) { ethtool_link_ksettings_add_link_mode(ks, supported, - 40000baseCR4_Full); + 40000baseCR4_Full); ethtool_link_ksettings_add_link_mode(ks, advertising, - 40000baseCR4_Full); + 40000baseCR4_Full); } if (supported_link & RNP_SFP_MODE_40G_SR4) { ethtool_link_ksettings_add_link_mode(ks, supported, - 40000baseSR4_Full); + 40000baseSR4_Full); ethtool_link_ksettings_add_link_mode(ks, advertising, - 40000baseSR4_Full); + 40000baseSR4_Full); } if (supported_link & RNP_SFP_MODE_40G_LR4) { ethtool_link_ksettings_add_link_mode(ks, supported, - 40000baseLR4_Full); + 40000baseLR4_Full); ethtool_link_ksettings_add_link_mode(ks, advertising, - 40000baseLR4_Full); + 40000baseLR4_Full); } /* add 25G support here */ @@ -2434,17 +2427,17 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, if (hw->is_backplane) { if (phy_type == PHY_TYPE_40G_BASE_KR4) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 40000baseKR4_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 40000baseKR4_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 40000baseKR4_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 40000baseKR4_Full); } if (phy_type == PHY_TYPE_10G_BASE_KR) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseKR_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseKR_Full); if (supported_link & RNP_LINK_SPEED_10GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseKR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseKR_Full); } } if (supported_link & RNP_SFP_MODE_1G_LX || @@ -2452,27 +2445,27 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, ethtool_link_ksettings_add_link_mode(ks, supported, 1000baseX_Full); if (supported_link & RNP_LINK_SPEED_1GB_FULL) { - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseX_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseX_Full); } } if (phy_type == PHY_TYPE_1G_BASE_KX) { if (hw->is_backplane) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 1000baseKX_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 1000baseKX_Full); if (supported_link & RNP_LINK_SPEED_1GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseKX_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseKX_Full); } if ((supported_link & RNP_SFP_MODE_1G_T) || - (supported_link & RNP_LINK_SPEED_1GB_FULL)) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 1000baseT_Full); + (supported_link & RNP_LINK_SPEED_1GB_FULL)) { + ethtool_link_ksettings_add_link_mode(ks, supported, + 1000baseT_Full); if (supported_link & RNP_LINK_SPEED_1GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseT_Full); } } @@ -2481,22 +2474,22 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, ethtool_link_ksettings_add_link_mode(ks, supported, 10000baseSR_Full); if (supported_link & RNP_LINK_SPEED_10GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseSR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseSR_Full); } if (phy_type == PHY_TYPE_10G_BASE_ER) { ethtool_link_ksettings_add_link_mode(ks, supported, 10000baseER_Full); if (supported_link & RNP_LINK_SPEED_10GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseER_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseER_Full); } if (phy_type == PHY_TYPE_10G_BASE_LR) { ethtool_link_ksettings_add_link_mode(ks, supported, 10000baseLR_Full); if (supported_link & RNP_LINK_SPEED_10GB_FULL) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseLR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseLR_Full); } if (hw->force_speed_stat == FORCE_SPEED_STAT_10G) { @@ -2511,17 +2504,18 @@ static void rnp_phy_type_to_ethtool(struct rnp_adapter *adapter, 1000baseX_Full); if (phy_type == PHY_TYPE_1G_BASE_KX) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseSR_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseSR_Full); - ethtool_link_ksettings_add_link_mode( - ks, supported, 10000baseLR_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseLR_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseSR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseSR_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 10000baseLR_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseLR_Full); } } } + /** * rnp_get_settings_link_up - Get Link settings for when link is up * @hw: hw structure @@ -2586,8 +2580,8 @@ static void rnp_get_settings_link_up(struct rnp_hw *hw, ethtool_link_ksettings_add_link_mode(ks, supported, 10000baseT_Full); if (hw->speed == SPEED_10000) - ethtool_link_ksettings_add_link_mode( - ks, advertising, 10000baseT_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 10000baseT_Full); break; case PHY_TYPE_1G_BASE_KX: ethtool_link_ksettings_add_link_mode(ks, supported, @@ -2595,10 +2589,10 @@ static void rnp_get_settings_link_up(struct rnp_hw *hw, ethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg); if (!!hw->is_backplane) { - ethtool_link_ksettings_add_link_mode( - ks, supported, 1000baseKX_Full); - ethtool_link_ksettings_add_link_mode( - ks, advertising, 1000baseKX_Full); + ethtool_link_ksettings_add_link_mode(ks, supported, + 1000baseKX_Full); + ethtool_link_ksettings_add_link_mode(ks, advertising, + 1000baseKX_Full); } ethtool_link_ksettings_add_link_mode(ks, supported, 1000baseX_Full); @@ -2777,18 +2771,18 @@ static int rnp_get_phy_mdix_from_hw(struct rnp_hw *hw) __maybe_unused static bool fiber_unsupport(u32 supported_link, u8 phy_type) { - if ((phy_type == PHY_TYPE_10G_BASE_KR) || - (phy_type == PHY_TYPE_10G_BASE_SR) || - (phy_type == PHY_TYPE_10G_BASE_LR) || - (phy_type == PHY_TYPE_10G_BASE_ER)) { + if (phy_type == PHY_TYPE_10G_BASE_KR || + phy_type == PHY_TYPE_10G_BASE_SR || + phy_type == PHY_TYPE_10G_BASE_LR || + phy_type == PHY_TYPE_10G_BASE_ER) { if (!(supported_link & RNP_LINK_SPEED_10GB_FULL)) return true; } - if ((phy_type == PHY_TYPE_40G_BASE_KR4) || - (phy_type == PHY_TYPE_40G_BASE_SR4) || - (phy_type == PHY_TYPE_40G_BASE_CR4) || - (phy_type == PHY_TYPE_40G_BASE_LR4)) { + if (phy_type == PHY_TYPE_40G_BASE_KR4 || + phy_type == PHY_TYPE_40G_BASE_SR4 || + phy_type == PHY_TYPE_40G_BASE_CR4 || + phy_type == PHY_TYPE_40G_BASE_LR4) { if (!(supported_link & (RNP_LINK_SPEED_40GB_FULL | RNP_LINK_SPEED_25GB_FULL))) return true; @@ -2802,8 +2796,8 @@ __maybe_unused static bool fiber_unsupport(u32 supported_link, u8 phy_type) return false; } -int rnp10_get_link_ksettings(struct net_device *netdev, - struct ethtool_link_ksettings *ks) +static int rnp10_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *ks) { struct rnp_adapter *adapter = netdev_priv(netdev); struct rnp_hw *hw = &adapter->hw; @@ -2906,12 +2900,13 @@ int rnp10_get_link_ksettings(struct net_device *netdev, if (hw->phy_type == PHY_TYPE_SGMII) ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); - if (ks->base.autoneg == AUTONEG_ENABLE) - ethtool_link_ksettings_add_link_mode( - ks, advertising, Autoneg); - else - ethtool_link_ksettings_del_link_mode( - ks, advertising, Autoneg); + if (ks->base.autoneg == AUTONEG_ENABLE) { + ethtool_link_ksettings_add_link_mode(ks, advertising, + Autoneg); + } else { + ethtool_link_ksettings_del_link_mode(ks, advertising, + Autoneg); + } ks->base.port = PORT_TP; break; case rnp_media_type_da: @@ -2949,23 +2944,23 @@ int rnp10_get_link_ksettings(struct net_device *netdev, switch (hw->fc.requested_mode) { case rnp_fc_full: ethtool_link_ksettings_add_link_mode(ks, advertising, - Pause); + Pause); break; case rnp_fc_tx_pause: ethtool_link_ksettings_add_link_mode(ks, advertising, - Asym_Pause); + Asym_Pause); break; case rnp_fc_rx_pause: ethtool_link_ksettings_add_link_mode(ks, advertising, - Pause); + Pause); ethtool_link_ksettings_add_link_mode(ks, advertising, - Asym_Pause); + Asym_Pause); break; default: ethtool_link_ksettings_del_link_mode(ks, advertising, - Pause); + Pause); ethtool_link_ksettings_del_link_mode(ks, advertising, - Asym_Pause); + Asym_Pause); break; } @@ -2990,24 +2985,23 @@ int rnp10_get_link_ksettings(struct net_device *netdev, #endif #endif /* ETH_TP_MDI_X */ rnp_logd(LOG_ETHTOOL, - "%s %s set link: speed=%d port=%d duplex=%d autoneg=%d", - __func__, netdev->name, ks->base.speed, ks->base.port, - ks->base.duplex, ks->base.autoneg); + "%s %s set link: speed=%d port=%d duplex=%d autoneg=%d", + __func__, netdev->name, ks->base.speed, ks->base.port, + ks->base.duplex, ks->base.autoneg); rnp_logd(LOG_ETHTOOL, - "phy_address=%d, media_type=%d hw->phy_type:%d\n", - ks->base.phy_address, - hw->phy.media_type, hw->phy_type); + "phy_address=%d, media_type=%d hw->phy_type:%d\n", + ks->base.phy_address, + hw->phy.media_type, hw->phy_type); return 0; } -int rnp10_set_link_ksettings(struct net_device *netdev, - const struct ethtool_link_ksettings *ks) +static int rnp10_set_link_ksettings(struct net_device *netdev, + const struct ethtool_link_ksettings *ks) { struct rnp_adapter *adapter = netdev_priv(netdev); struct rnp_hw *hw = &adapter->hw; struct ethtool_link_ksettings safe_ks; struct ethtool_link_ksettings copy_ks; - bool autoneg_changed = false, duplex_changed = false; int timeout = 50; int err = 0; u8 autoneg; @@ -3019,12 +3013,12 @@ int rnp10_set_link_ksettings(struct net_device *netdev, /* save autoneg out of ksettings */ autoneg = copy_ks.base.autoneg; rnp_logd(LOG_ETHTOOL, - "%s %s set link: speed=%d port=%d duplex=%d autoneg=%d", - __func__, netdev->name, copy_ks.base.speed, - copy_ks.base.port, copy_ks.base.duplex, - copy_ks.base.autoneg); + "%s %s set link: speed=%d port=%d duplex=%d autoneg=%d", + __func__, netdev->name, copy_ks.base.speed, + copy_ks.base.port, copy_ks.base.duplex, + copy_ks.base.autoneg); rnp_logd(LOG_ETHTOOL, - "phy_address=%d\n", copy_ks.base.phy_address); + "phy_address=%d\n", copy_ks.base.phy_address); /* get our own copy of the bits to check against */ memset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings)); @@ -3053,16 +3047,14 @@ int rnp10_set_link_ksettings(struct net_device *netdev, /* If autoneg was not already enabled */ if (!(adapter->an)) { /* If autoneg is not supported, return error */ - if (!ethtool_link_ksettings_test_link_mode( - &safe_ks, supported, Autoneg)) { - netdev_info( - netdev, - "Autoneg not supported on this phy\n"); + if (!ethtool_link_ksettings_test_link_mode(&safe_ks, + supported, + Autoneg)) { + netdev_info(netdev, + "Autoneg not supported on this phy\n"); err = -EINVAL; goto done; } - /* Autoneg is allowed to change */ - autoneg_changed = true; } if (ethtool_link_ksettings_test_link_mode(ks, advertising, @@ -3071,10 +3063,10 @@ int rnp10_set_link_ksettings(struct net_device *netdev, if (ethtool_link_ksettings_test_link_mode(ks, advertising, 100baseT_Full)) advertising_link_speed |= RNP_LINK_SPEED_100_FULL; - if (ethtool_link_ksettings_test_link_mode( - ks, advertising, 1000baseT_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 1000baseX_Full) || + if (ethtool_link_ksettings_test_link_mode(ks, advertising, + 1000baseT_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 1000baseX_Full) || ethtool_link_ksettings_test_link_mode(ks, advertising, 1000baseKX_Full)) advertising_link_speed |= RNP_LINK_SPEED_1GB_FULL; @@ -3088,45 +3080,43 @@ int rnp10_set_link_ksettings(struct net_device *netdev, if (ethtool_link_ksettings_test_link_mode(ks, advertising, 1000baseT_Half)) advertising_link_speed |= RNP_LINK_SPEED_1GB_HALF; - if (ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseT_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseKX4_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseKR_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseCR_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseSR_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 10000baseLR_Full)) + if (ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseT_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseKX4_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseKR_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseCR_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseSR_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 10000baseLR_Full)) advertising_link_speed |= RNP_LINK_SPEED_10GB_FULL; - if (ethtool_link_ksettings_test_link_mode( - ks, advertising, 40000baseKR4_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 40000baseCR4_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 40000baseSR4_Full) || - ethtool_link_ksettings_test_link_mode( - ks, advertising, 40000baseLR4_Full)) + if (ethtool_link_ksettings_test_link_mode(ks, advertising, + 40000baseKR4_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 40000baseCR4_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 40000baseSR4_Full) || + ethtool_link_ksettings_test_link_mode(ks, advertising, + 40000baseLR4_Full)) advertising_link_speed |= RNP_LINK_SPEED_40GB_FULL; if (advertising_link_speed) { hw->phy.autoneg_advertised = advertising_link_speed; } else { - if ((hw->force_speed_stat == - FORCE_SPEED_STAT_DISABLED)) { + if (hw->force_speed_stat == + FORCE_SPEED_STAT_DISABLED) { netdev_info(netdev, - "advertising_link_speed is 0\n"); + "advertising_link_speed is 0\n"); err = -EINVAL; goto done; } } - if (hw->is_sgmii && hw->autoneg == false) - autoneg_changed = true; hw->autoneg = true; } else { /* If autoneg is currently enabled */ @@ -3134,16 +3124,15 @@ int rnp10_set_link_ksettings(struct net_device *netdev, /* If autoneg is supported 10GBASE_T is the only PHY * that can disable it, so otherwise return error */ - if (ethtool_link_ksettings_test_link_mode( - &safe_ks, supported, Autoneg) && + if (ethtool_link_ksettings_test_link_mode(&safe_ks, + supported, + Autoneg) && hw->phy.media_type != rnp_media_type_copper) { netdev_info(netdev, - "Autoneg cannot be disabled on this phy\n"); + "Autoneg cannot be disabled on this phy\n"); err = -EINVAL; goto done; } - /* Autoneg is allowed to change */ - autoneg_changed = true; } /* Only allow one speed at a time when autoneg is AUTONEG_DISABLE. */ @@ -3174,10 +3163,8 @@ int rnp10_set_link_ksettings(struct net_device *netdev, * This is needed because if advertise is 0 (as it is when autoneg * is disabled) then speed won't get set. */ - if (hw->is_sgmii) { + if (hw->is_sgmii) hw->duplex = ks->base.duplex; - duplex_changed = true; - } /* this sets the link speed and restarts auto-neg */ while (test_and_set_bit(__RNP_IN_SFP_INIT, &adapter->state)) { @@ -3219,10 +3206,10 @@ static void rnp10_get_drvinfo(struct net_device *netdev, rnp_driver_version, hw->pcode); snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), - "%d.%d.%d.%d 0x%08x", ((char *)&(hw->fw_version))[3], - ((char *)&(hw->fw_version))[2], - ((char *)&(hw->fw_version))[1], - ((char *)&(hw->fw_version))[0], hw->bd_uid); + "%d.%d.%d.%d 0x%08x", ((char *)&hw->fw_version)[3], + ((char *)&hw->fw_version)[2], + ((char *)&hw->fw_version)[1], + ((char *)&hw->fw_version)[0], hw->bd_uid); strscpy(drvinfo->bus_info, pci_name(adapter->pdev), sizeof(drvinfo->bus_info)); @@ -3246,7 +3233,7 @@ static void rnp10_get_regs(struct net_device *netdev, regs_buff[i] = rd32(hw, i * 4); } -int rnp_nway_reset(struct net_device *netdev) +static int rnp_nway_reset(struct net_device *netdev) { struct rnp_adapter *adapter = netdev_priv(netdev); @@ -3258,7 +3245,7 @@ int rnp_nway_reset(struct net_device *netdev) } /** - * rnpm_device_supports_autoneg_fc - Check if phy supports autoneg flow + * rnp_device_supports_autoneg_fc - Check if phy supports autoneg flow * control * @hw: pointer to hardware structure * @@ -3266,7 +3253,7 @@ int rnp_nway_reset(struct net_device *netdev) * function check the device id to see if the associated phy supports * autoneg flow control. **/ -bool rnp_device_supports_autoneg_fc(struct rnp_hw *hw) +static bool rnp_device_supports_autoneg_fc(struct rnp_hw *hw) { bool supported = false; @@ -3320,7 +3307,7 @@ static int rnp10_set_pauseparam(struct net_device *netdev, return -EINVAL; /* we not support autoneg mode */ - if ((pause->autoneg == AUTONEG_ENABLE) && + if (pause->autoneg == AUTONEG_ENABLE && !rnp_device_supports_autoneg_fc(hw)) return -EINVAL; @@ -3350,8 +3337,9 @@ static int rnp10_set_pauseparam(struct net_device *netdev, } else if ((!(hw->fc.requested_mode & PAUSE_TX)) && (!(hw->fc.requested_mode & PAUSE_RX))) { - } else + } else { pause_bits |= ASYM_PAUSE | SYM_PAUSE; + } } rnp_mbx_phy_read(hw, 4, &value); value &= ~0xC00; @@ -3365,7 +3353,6 @@ static int rnp10_set_pauseparam(struct net_device *netdev, } } - /* if the thing changed then we'll update and use new autoneg */ if (memcmp(&fc, &hw->fc, sizeof(struct rnp_fc_info))) { /* to tell all vf new pause status */ @@ -3383,11 +3370,8 @@ static int rnp10_set_pauseparam(struct net_device *netdev, static void rnp10_get_strings(struct net_device *netdev, u32 stringset, u8 *data) { - struct rnp_adapter *adapter = netdev_priv(netdev); char *p = (char *)data; int i; - struct rnp_ring *ring; - u32 dma_ch; switch (stringset) { case ETH_SS_TEST: @@ -3410,8 +3394,6 @@ static void rnp10_get_strings(struct net_device *netdev, u32 stringset, } for (i = 0; i < RNP_NUM_TX_QUEUES; i++) { /* ==== tx ======== */ - ring = adapter->tx_ring[i]; - dma_ch = ring->rnp_queue_idx; sprintf(p, "---\n queue%u_tx_packets", i); p += ETH_GSTRING_LEN; sprintf(p, "queue%u_tx_bytes", i); @@ -3462,8 +3444,6 @@ static void rnp10_get_strings(struct net_device *netdev, u32 stringset, p += ETH_GSTRING_LEN; /* ==== rx ======== */ - ring = adapter->rx_ring[i]; - dma_ch = ring->rnp_queue_idx; sprintf(p, "queue%u_rx_packets", i); p += ETH_GSTRING_LEN; sprintf(p, "queue%u_rx_bytes", i); @@ -3483,10 +3463,10 @@ static void rnp10_get_strings(struct net_device *netdev, u32 stringset, p += ETH_GSTRING_LEN; sprintf(p, "queue%u_rx_alloc_page", i); p += ETH_GSTRING_LEN; - sprintf(p, "queue%u_rx_csum_offload_errs", i); - p += ETH_GSTRING_LEN; - sprintf(p, "queue%u_rx_csum_offload_good", i); - p += ETH_GSTRING_LEN; + //sprintf(p, "queue%u_rx_csum_offload_errs", i); + //p += ETH_GSTRING_LEN; + //sprintf(p, "queue%u_rx_csum_offload_good", i); + //p += ETH_GSTRING_LEN; sprintf(p, "queue%u_rx_poll_again_count", i); p += ETH_GSTRING_LEN; sprintf(p, "queue%u_rx_rm_vlan_packets", i); @@ -3522,7 +3502,6 @@ static void rnp10_get_strings(struct net_device *netdev, u32 stringset, } } - static int rnp10_get_sset_count(struct net_device *netdev, int sset) { switch (sset) { @@ -3570,7 +3549,6 @@ static u32 rnp10_get_priv_flags(struct net_device *netdev) if (adapter->priv_flags & RNP_PRIV_FLAG_LLDP_EN_STAT) priv_flags |= RNP10_LLDP_EN_STAT; - return priv_flags; } @@ -3599,8 +3577,8 @@ static int rnp10_set_priv_flags(struct net_device *netdev, u32 priv_flags) if (rnp_mbx_lldp_port_enable(hw, true) == 0) { adapter->priv_flags |= RNP_PRIV_FLAG_LLDP_EN_STAT; } else { - rnp_err("%s: set lldp enable faild!\n", - adapter->netdev->name); + rnp_err("%s: set lldp enable failed!\n", + adapter->netdev->name); adapter->priv_flags &= (~RNP_PRIV_FLAG_LLDP_EN_STAT); } @@ -3727,7 +3705,6 @@ static int rnp10_set_priv_flags(struct net_device *netdev, u32 priv_flags) return 0; } - static void rnp10_get_ethtool_stats(struct net_device *netdev, struct ethtool_stats *stats, u64 *data) { @@ -3758,7 +3735,6 @@ static void rnp10_get_ethtool_stats(struct net_device *netdev, BUG_ON(RNP_NUM_TX_QUEUES != RNP_NUM_RX_QUEUES); for (j = 0; j < RNP_NUM_TX_QUEUES; j++) { - int idx; /* tx-ring */ ring = adapter->tx_ring[j]; if (!ring) { @@ -3810,7 +3786,6 @@ static void rnp10_get_ethtool_stats(struct net_device *netdev, data[i++] = 0; continue; } - idx = ring->rnp_queue_idx; data[i++] = ring->stats.packets; data[i++] = ring->stats.bytes; @@ -3869,7 +3844,6 @@ static void rnp10_get_ethtool_stats(struct net_device *netdev, data[i++] = 0; continue; } - idx = ring->rnp_queue_idx; data[i++] = ring->stats.packets; data[i++] = ring->stats.bytes; @@ -3880,8 +3854,8 @@ static void rnp10_get_ethtool_stats(struct net_device *netdev, data[i++] = ring->rx_stats.alloc_rx_page_failed; data[i++] = ring->rx_stats.alloc_rx_buff_failed; data[i++] = ring->rx_stats.alloc_rx_page; - data[i++] = ring->rx_stats.csum_err; - data[i++] = ring->rx_stats.csum_good; + //data[i++] = ring->rx_stats.csum_err; + //data[i++] = ring->rx_stats.csum_good; data[i++] = ring->rx_stats.poll_again_count; data[i++] = ring->rx_stats.vlan_remove; @@ -3947,7 +3921,7 @@ static const struct ethtool_ops rnp10_ethtool_ops = { .flash_device = rnp_flash_device, }; -void rnp_set_ethtool_hw_ops_n10(struct net_device *netdev) +static void rnp_set_ethtool_hw_ops_n10(struct net_device *netdev) { netdev->ethtool_ops = &rnp10_ethtool_ops; } @@ -3957,7 +3931,7 @@ void rnp_set_ethtool_hw_ops_n10(struct net_device *netdev) * @hw: pointer to hardware structure * Returns the thermal sensor data structure **/ -s32 rnp_get_thermal_sensor_data_hw_ops_n10(struct rnp_hw *hw) +static s32 rnp_get_thermal_sensor_data_hw_ops_n10(struct rnp_hw *hw) { int voltage = 0; struct rnp_thermal_sensor_data *data = &hw->thermal_sensor_data; @@ -3973,7 +3947,7 @@ s32 rnp_get_thermal_sensor_data_hw_ops_n10(struct rnp_hw *hw) * Inits the thermal sensor thresholds according to the NVM map * and save off the threshold and location values into mac.thermal_sensor_data **/ -s32 rnp_init_thermal_sensor_thresh_hw_ops_n10(struct rnp_hw *hw) +static s32 rnp_init_thermal_sensor_thresh_hw_ops_n10(struct rnp_hw *hw) { u8 i; struct rnp_thermal_sensor_data *data = &hw->thermal_sensor_data; @@ -3987,8 +3961,8 @@ s32 rnp_init_thermal_sensor_thresh_hw_ops_n10(struct rnp_hw *hw) return 0; } -s32 rnp_phy_read_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, - u32 device_type, u16 *phy_data) +static s32 rnp_phy_read_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, + u32 device_type, u16 *phy_data) { s32 status = 0; u32 data = 0; @@ -3999,8 +3973,8 @@ s32 rnp_phy_read_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, return status; } -s32 rnp_phy_write_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, - u32 device_type, u16 phy_data) +static s32 rnp_phy_write_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, + u32 device_type, u16 phy_data) { s32 status = 0; @@ -4009,8 +3983,8 @@ s32 rnp_phy_write_reg_hw_ops_n10(struct rnp_hw *hw, u32 reg_addr, return status; } -void rnp_set_vf_vlan_mode_hw_ops_n10(struct rnp_hw *hw, u16 vlan, int vf, - bool enable) +static void rnp_set_vf_vlan_mode_hw_ops_n10(struct rnp_hw *hw, u16 vlan, int vf, + bool enable) { struct rnp_eth_info *eth = &hw->eth; struct rnp_adapter *adapter = (struct rnp_adapter *)hw->back; @@ -4085,7 +4059,7 @@ static void rnp_mac_set_rx_n10(struct rnp_mac_info *mac, bool status) do { mac_wr32(mac, RNP10_MAC_RX_CFG, mac_rd32(mac, RNP10_MAC_RX_CFG) | - 0x01 | RNP_IPC_MASK_XLGMAC); + 0x01); usleep_range(100, 200); value = mac_rd32(mac, RNP10_MAC_RX_CFG); count++; @@ -4128,6 +4102,7 @@ static void rnp_mac_set_rx_n10(struct rnp_mac_info *mac, bool status) mac_wr32(mac, RNP10_MAC_PKT_FLT, 0x0); } } + static void rnp_mac_fcs_n10(struct rnp_mac_info *mac, bool status) { u32 value; @@ -4143,12 +4118,12 @@ static void rnp_mac_fcs_n10(struct rnp_mac_info *mac, bool status) } /** - * rnp_fc_mode_n10 - Enable flow control - * @hw: pointer to hardware structure + * rnp_mac_fc_mode_n10 - Enable flow control + * @mac: pointer to hardware structure * * Enable flow control according to the current settings. **/ -s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) +static s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) { struct rnp_hw *hw = (struct rnp_hw *)mac->back; s32 ret_val = 0; @@ -4156,8 +4131,7 @@ s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) u32 rxctl_reg, txctl_reg[RNP_MAX_TRAFFIC_CLASS]; int i; - /* - * Validate the water mark configuration for packet buffer 0. Zero + /* Validate the water mark configuration for packet buffer 0. Zero * water marks indicate that the packet buffer was not configured * and the watermarks for packet buffer 0 should always be configured. */ @@ -4174,8 +4148,7 @@ s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) txctl_reg[i] = mac_rd32(mac, RNP10_MAC_Q0_TX_FLOW_CTRL(i)); txctl_reg[i] &= (~RNP10_TX_FLOW_ENABLE_MASK); } - /* - * The possible values of fc.current_mode are: + /* The possible values of fc.current_mode are: * 0: Flow control is completely disabled * 1: Rx flow control is enabled (we can receive pause frames, * but not send pause frames). @@ -4186,14 +4159,12 @@ s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) */ switch (hw->fc.current_mode) { case rnp_fc_none: - /* - * Flow control is disabled by software override or autoneg. + /* Flow control is disabled by software override or autoneg. * The code below will actually disable it in the HW. */ break; case rnp_fc_rx_pause: - /* - * Rx Flow control is enabled and Tx Flow control is + /* Rx Flow control is enabled and Tx Flow control is * disabled by software override. Since there really * isn't a way to advertise that we are capable of RX * Pause ONLY, we will advertise that we support both @@ -4203,8 +4174,7 @@ s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) rxctl_reg |= (RNP10_RX_FLOW_ENABLE_MASK); break; case rnp_fc_tx_pause: - /* - * Tx Flow control is enabled, and Rx Flow control is + /* Tx Flow control is enabled, and Rx Flow control is * disabled by software override. */ for (i = 0; i < RNP_MAX_TRAFFIC_CLASS; i++) @@ -4235,7 +4205,7 @@ s32 rnp_mac_fc_mode_n10(struct rnp_mac_info *mac) return ret_val; } -void rnp_mac_set_mac_n10(struct rnp_mac_info *mac, u8 *addr, int index) +static void rnp_mac_set_mac_n10(struct rnp_mac_info *mac, u8 *addr, int index) { u32 rar_low, rar_high = 0; diff --git a/drivers/net/ethernet/mucse/rnp/rnp_ptp.c b/drivers/net/ethernet/mucse/rnp/rnp_ptp.c index ccb8e965594c..d7fcea8d7914 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_ptp.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_ptp.c @@ -11,7 +11,6 @@ #include "rnp_regs.h" #include "rnp_ptp.h" - /* PTP and HW Timer ops */ static void config_hw_tstamping(void __iomem *ioaddr, u32 data) { @@ -182,7 +181,7 @@ static int rnp_ptp_adjfreq(struct ptp_clock_info *ptp, long scaled_ppm) unsigned long flags; u32 addend; - if (pf == NULL) { + if (!pf) { printk(KERN_DEBUG "adapter_of contail is null\n"); return 0; } @@ -257,7 +256,6 @@ static int rnp_ptp_settime(struct ptp_clock_info *ptp, return 0; } - static int rnp_ptp_feature_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *rq, int on) { @@ -274,7 +272,7 @@ int rnp_ptp_get_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) 0; } -int rnp_ptp_setup_ptp(struct rnp_adapter *pf, u32 value) +static int rnp_ptp_setup_ptp(struct rnp_adapter *pf, u32 value) { u32 sec_inc = 0; u64 temp = 0; @@ -293,14 +291,16 @@ int rnp_ptp_setup_ptp(struct rnp_adapter *pf, u32 value) /* program Sub Second Increment reg * we use kernel-system clock */ - pf->hwts_ops->config_sub_second_increment( - pf->ptp_addr, pf->clk_ptp_rate, pf->gmac4, &sec_inc); + pf->hwts_ops->config_sub_second_increment(pf->ptp_addr, + pf->clk_ptp_rate, + pf->gmac4, + &sec_inc); /* 4.If use fine correction approash then, * Program MAC_Timestamp_Addend register */ if (sec_inc == 0) { pr_info("%s:%d the sec_inc is zero this is a bug\n", - __func__, __LINE__); + __func__, __LINE__); return -EFAULT; } temp = div_u64(1000000000ULL, sec_inc); @@ -347,7 +347,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) u32 ptp_over_ethernet = 0; u32 snap_type_sel = 0; u32 ts_master_en = 0; - u32 ts_event_en = 0; u32 value = 0; s32 ret = -1; @@ -398,7 +397,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) /* PTP v1, UDP, Sync packet */ config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_SYNC; /* take time stamp for SYNC messages only */ - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; @@ -409,7 +407,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) config.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ; /* take time stamp for Delay_Req messages only */ ts_master_en = RNP_PTP_TCR_TSMSTRENA; - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; @@ -432,7 +429,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_SYNC; ptp_v2 = RNP_PTP_TCR_TSVER2ENA; /* take time stamp for SYNC messages only */ - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; break; @@ -443,7 +439,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) ptp_v2 = RNP_PTP_TCR_TSVER2ENA; /* take time stamp for Delay_Req messages only */ ts_master_en = RNP_PTP_TCR_TSMSTRENA; - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; break; @@ -453,7 +448,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) config.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; ptp_v2 = RNP_PTP_TCR_TSVER2ENA; snap_type_sel = RNP_PTP_TCR_SNAPTYPSEL_1; - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; ptp_over_ethernet = RNP_PTP_TCR_TSIPENA; @@ -464,7 +458,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) config.rx_filter = HWTSTAMP_FILTER_PTP_V2_SYNC; ptp_v2 = RNP_PTP_TCR_TSVER2ENA; /* take time stamp for SYNC messages only */ - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; ptp_over_ethernet = RNP_PTP_TCR_TSIPENA; @@ -476,7 +469,6 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) ptp_v2 = RNP_PTP_TCR_TSVER2ENA; /* take time stamp for Delay_Req messages only */ ts_master_en = RNP_PTP_TCR_TSMSTRENA; - ts_event_en = RNP_PTP_TCR_TSEVNTENA; ptp_over_ipv4_udp = RNP_PTP_TCR_TSIPV4ENA; ptp_over_ipv6_udp = RNP_PTP_TCR_TSIPV6ENA; @@ -498,21 +490,18 @@ int rnp_ptp_set_ts_config(struct rnp_adapter *pf, struct ifreq *ifr) ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); pf->ptp_tx_en = config.tx_type == HWTSTAMP_TX_ON; - netdev_info( - pf->netdev, - "ptp config rx filter 0x%.2x tx_type 0x%.2x rx_en[%d] tx_en[%d]\n", - config.rx_filter, config.tx_type, pf->ptp_rx_en, - pf->ptp_tx_en); - if (!pf->ptp_rx_en && !pf->ptp_tx_en) + netdev_info(pf->netdev, + "ptp config rx filter 0x%.2x tx_type 0x%.2x rx_en[%d] tx_en[%d]\n", + config.rx_filter, config.tx_type, pf->ptp_rx_en, + pf->ptp_tx_en); + if (!pf->ptp_rx_en && !pf->ptp_tx_en) { /*rx and tx is not use hardware ts so clear the ptp register */ pf->hwts_ops->config_hw_tstamping(pf->ptp_addr, 0); - else { + } else { value = (RNP_PTP_TCR_TSENA | RNP_PTP_TCR_TSCFUPDT | RNP_PTP_TCR_TSCTRLSSR | tstamp_all | ptp_v2 | ptp_over_ethernet | ptp_over_ipv6_udp | ptp_over_ipv4_udp | ts_master_en | snap_type_sel); - //ptp_over_ipv4_udp | ts_event_en | ts_master_en | - //snap_type_sel); ret = rnp_ptp_setup_ptp(pf, value); if (ret < 0) @@ -555,12 +544,12 @@ int rnp_ptp_register(struct rnp_adapter *pf) /*default mac clock rate is 100Mhz */ pf->clk_ptp_rate = 50000000; // 100Mhz - if (pf->pdev == NULL) + if (!pf->pdev) pr_info("pdev dev is null\n"); pf->ptp_clock = ptp_clock_register(&pf->ptp_clock_ops, &pf->pdev->dev); - if (pf->ptp_clock == NULL) + if (!pf->ptp_clock) pci_err(pf->pdev, "ptp clock register failed\n"); if (IS_ERR(pf->ptp_clock)) { @@ -584,8 +573,6 @@ void rnp_ptp_unregister(struct rnp_adapter *pf) } } - - void rnp_tx_hwtstamp_work(struct work_struct *work) { struct rnp_adapter *adapter = @@ -673,7 +660,7 @@ void rnp_ptp_get_rx_hwstamp(struct rnp_adapter *adapter, return; } - if (likely(!((desc->wb.cmd) & RNP_RXD_STAT_PTP))) + if (likely(!(desc->wb.cmd & RNP_RXD_STAT_PTP))) return; hwtstamps = skb_hwtstamps(skb); /* because of rx hwstamp store before the mac head @@ -686,9 +673,9 @@ void rnp_ptp_get_rx_hwstamp(struct rnp_adapter *adapter, */ skb_copy_from_linear_data_offset(skb, RNP_RX_TIME_RESERVE, &tsvalueh, RNP_RX_SEC_SIZE); - skb_copy_from_linear_data_offset( - skb, RNP_RX_TIME_RESERVE + RNP_RX_SEC_SIZE, &tsvaluel, - RNP_RX_NANOSEC_SIZE); + skb_copy_from_linear_data_offset(skb, RNP_RX_TIME_RESERVE + + RNP_RX_SEC_SIZE, &tsvaluel, + RNP_RX_NANOSEC_SIZE); skb_pull(skb, RNP_RX_HWTS_OFFSET); tsvalueh = ntohl(tsvalueh); tsvaluel = ntohl(tsvaluel); diff --git a/drivers/net/ethernet/mucse/rnp/rnp_sriov.c b/drivers/net/ethernet/mucse/rnp/rnp_sriov.c index d3ccb88eafa0..b8b7ff18871b 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_sriov.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_sriov.c @@ -48,13 +48,16 @@ static int __rnp_enable_sriov(struct rnp_adapter *adapter) (hw->max_pf_macvlans + 1 + adapter->num_vfs); num_vebvlans = hw->num_vebvlan_entries; - adapter->mv_list = mv_list = kcalloc( - num_vf_macvlans, sizeof(struct vf_macvlans), GFP_KERNEL); - if (num_vebvlans) - hw->vv_list = vv_list = kcalloc(num_vebvlans, - sizeof(struct vf_vebvlans), - GFP_KERNEL); - + mv_list = kcalloc(num_vf_macvlans, + sizeof(struct vf_macvlans), + GFP_KERNEL); + adapter->mv_list = mv_list; + if (num_vebvlans) { + vv_list = kcalloc(num_vebvlans, + sizeof(struct vf_vebvlans), + GFP_KERNEL); + hw->vv_list = vv_list; + } if (mv_list) { /* Initialize list of VF macvlans */ INIT_LIST_HEAD(&adapter->vf_mvs.l); @@ -84,8 +87,8 @@ static int __rnp_enable_sriov(struct rnp_adapter *adapter) adapter->flags2 |= RNP_FLAG2_BRIDGE_MODE_VEB; hw->ops.set_sriov_status(hw, true); adapter->vfinfo = kcalloc(adapter->num_vfs, - sizeof(struct vf_data_storage), - GFP_KERNEL); + sizeof(struct vf_data_storage), + GFP_KERNEL); if (adapter->vfinfo) { /* We do not support RSS w/ SR-IOV */ adapter->ring_feature[RING_F_RSS].limit = @@ -113,7 +116,7 @@ void rnp_enable_sriov_true(struct rnp_adapter *adapter) err = pci_enable_sriov(adapter->pdev, adapter->num_vfs); if (err) { e_err(drv, "Failed to enable PCI sriov: %d num %d\n", err, - adapter->num_vfs); + adapter->num_vfs); e_err(drv, "We cannot handle this error\n"); } @@ -135,9 +138,9 @@ void rnp_enable_sriov(struct rnp_adapter *adapter) if (!pre_existing_vfs) { dev_warn(&adapter->pdev->dev, - "Enabling SR-IOV VFs using the module parameter is deprecated"); + "Enabling SR-IOV VFs using the module parameter is deprecated"); dev_warn(&adapter->pdev->dev, - "- please use the pci sysfs interface.\n"); + "- please use the pci sysfs interface.\n"); } /* If there are pre-existing VFs then we have to force @@ -149,13 +152,12 @@ void rnp_enable_sriov(struct rnp_adapter *adapter) if (pre_existing_vfs) { adapter->num_vfs = pre_existing_vfs; dev_warn(&adapter->pdev->dev, - "Virtual Functions already enabled for this device - Please"); + "Virtual Functions already enabled for this device - Please"); dev_warn(&adapter->pdev->dev, - "reload all VF drivers to avoid spoofed packet errors\n"); + "reload all VF drivers to avoid spoofed packet errors\n"); } else { int i; - /* - * The n10 supports up to 64 VFs per physical function + /* The n10 supports up to 64 VFs per physical function * but this implementation limits allocation to 126 so that * basic networking resources are still available to the * physical function. If the user requests greater than @@ -172,7 +174,6 @@ void rnp_enable_sriov(struct rnp_adapter *adapter) for (i = 0; i < adapter->num_vfs; i++) rnp_vf_configuration(adapter->pdev, (i | 0x10000000)); - } } @@ -266,14 +267,12 @@ int rnp_disable_sriov(struct rnp_adapter *adapter) /* if SR-IOV is already disabled then there is nothing to do */ #ifdef CONFIG_PCI_IOV - /* - * If our VFs are assigned we cannot shut down SR-IOV + /* If our VFs are assigned we cannot shut down SR-IOV * without causing issues, so just leave the hardware * available but disabled */ if (rnp_vfs_are_assigned(adapter)) { - e_dev_warn( - "Unloading driver while VFs are assigned - VFs will not be"); + e_dev_warn("Unloading driver while VFs are assigned"); e_dev_warn("deallocated\n"); return -EPERM; @@ -302,7 +301,7 @@ int rnp_disable_sriov(struct rnp_adapter *adapter) return 0; } -bool check_ari_mode(struct pci_dev *dev) +static bool check_ari_mode(struct pci_dev *dev) { struct pci_bus *bus = dev->bus; @@ -426,15 +425,13 @@ static int rnp_set_vf_multicasts(struct rnp_adapter *adapter, u32 *msgbuf, /* only so many hash values supported */ entries = min(entries, RNP_MAX_VF_MC_ENTRIES); - /* - * salt away the number of multi cast addresses assigned + /* salt away the number of multi cast addresses assigned * to this VF for later use to restore when the PF multi cast * list changes */ vfinfo->num_vf_mc_hashes = entries; - /* - * VFs are limited to using the MTA hash table for their multicast + /* VFs are limited to using the MTA hash table for their multicast * addresses */ for (i = 0; i < entries; i++) @@ -463,7 +460,6 @@ void rnp_restore_vf_macs(struct rnp_adapter *adapter) } else { hw->ops.set_rar_with_vf(hw, mac_addr, rar_entry, vf, true); } - } } @@ -523,14 +519,12 @@ static int rnp_set_vf_vlan(struct rnp_adapter *adapter, int add, int vid, &adapter->state)) { for (i = 0; i < adapter->num_vfs; i++) { /* check if other vf_vlan still valid */ - if ((i != vf) && - (vid == - adapter->vfinfo[i].vf_vlan)) + if (i != vf && + vid == adapter->vfinfo[i].vf_vlan) true_handle = 0; /* check if other pf_vlan still valid */ - if ((i != vf) && - (vid == - adapter->vfinfo[i].pf_vlan)) + if (i != vf && + vid == adapter->vfinfo[i].pf_vlan) true_handle = 0; } clear_bit(__RNP_USE_VFINFI, @@ -541,7 +535,6 @@ static int rnp_set_vf_vlan(struct rnp_adapter *adapter, int add, int vid, if (true_handle) hw->ops.set_vf_vlan_filter(hw, vid, vf, (bool)add, false); - return 0; } @@ -611,8 +604,7 @@ static int rnp_set_vf_macvlan(struct rnp_adapter *adapter, int vf, } } - /* - * If index was zero then we were asked to clear the uc list + /* If index was zero then we were asked to clear the uc list * for the VF. We're done. */ if (!index) @@ -626,8 +618,7 @@ static int rnp_set_vf_macvlan(struct rnp_adapter *adapter, int vf, break; } - /* - * If we traversed the entire list and didn't find a free entry + /* If we traversed the entire list and didn't find a free entry * then we're out of space on the RAR table. Also entry may * be NULL because the original memory allocation for the list * failed, which is not fatal but does mean we can't support @@ -702,14 +693,13 @@ static int rnp_vf_reset_msg(struct rnp_adapter *adapter, u32 vf) } else { msgbuf[0] |= RNP_VT_MSGTYPE_NACK; dev_warn(&adapter->pdev->dev, - "VF %d has no MAC address assigned, you may have to assign", - vf); + "VF %d has no MAC address assigned, you may have to assign", + vf); dev_warn(&adapter->pdev->dev, - "one manually\n"); + "one manually\n"); } - /* - * Piggyback the multicast filter type so VF can compute the + /* Piggyback the multicast filter type so VF can compute the * correct vectors */ msgbuf[RNP_VF_MC_TYPE_WORD] = 0; @@ -805,7 +795,7 @@ static int rnp_set_vf_vlan_msg(struct rnp_adapter *adapter, u32 *msgbuf, return -1; } /* only allow 1 vlan for each vf */ - if ((add) && (adapter->vfinfo[vf].vlan_count)) { + if ((add) && adapter->vfinfo[vf].vlan_count) { e_warn(drv, "VF %d attempted to set more than 1 vlan", vf); e_warn(drv, " vlan now %d, try to set %d\n", adapter->vfinfo[vf].vf_vlan, vid); @@ -838,7 +828,7 @@ static int rnp_set_vf_vlan_strip_msg(struct rnp_adapter *adapter, int err = 0, i; vf_dbg("strip_on:%d queeu_cnt:%d, %d %d\n", vlan_strip_on, - queue_cnt, msgbuf[2], msgbuf[3]); + queue_cnt, msgbuf[2], msgbuf[3]); for (i = 0; i < queue_cnt; i++) { if (vlan_strip_on) @@ -905,9 +895,8 @@ static int rnp_set_vf_mtu(struct rnp_adapter *adapter, u32 *msgbuf, u32 vf) struct net_device *netdev = adapter->netdev; if (msgbuf[1] > netdev->mtu) { - e_dev_warn( - "vf %d try to change %d mtu to %d (large than pf limit)\n", - vf, netdev->mtu, msgbuf[1]); + e_dev_warn("vf %d try to change %d mtu to %d (pf limit)\n", + vf, netdev->mtu, msgbuf[1]); return -1; } else { return 0; @@ -938,9 +927,9 @@ static int rnp_get_vf_link(struct rnp_adapter *adapter, u32 *msgbuf, if (adapter->vfinfo[vf].link_state == rnp_link_state_auto) { msgbuf[1] = (adapter->link_up ? RNP_PF_LINK_UP : 0) | adapter->link_speed; - } else if (adapter->vfinfo[vf].link_state == rnp_link_state_on) + } else if (adapter->vfinfo[vf].link_state == rnp_link_state_on) { msgbuf[1] = RNP_PF_LINK_UP | adapter->link_speed; - else { + } else { msgbuf[1] = 0; } return 0; @@ -1011,8 +1000,7 @@ static int rnp_rcv_msg_from_vf(struct rnp_adapter *adapter, u32 vf) if ((msgbuf[0] & RNP_MAIL_CMD_MASK) == RNP_VF_RESET) return rnp_vf_reset_msg(adapter, vf); - /* - * until the vf completes a virtual function reset it should not be + /* until the vf completes a virtual function reset it should not be * allowed to start any configuration. */ if (!adapter->vfinfo[vf].clear_to_send) { @@ -1137,8 +1125,8 @@ void rnp_msg_task(struct rnp_adapter *adapter) } } -int rnp_msg_post_status_signle_link(struct rnp_adapter *adapter, int vf, - int link_state) +static int rnp_msg_post_status_signle_link(struct rnp_adapter *adapter, int vf, + int link_state) { u32 msgbuf[RNP_VFMAILBOX_SIZE]; struct rnp_hw *hw = &adapter->hw; @@ -1245,7 +1233,7 @@ int rnp_msg_post_status(struct rnp_adapter *adapter, enum PF_STATUS status) if (!test_bit(__RNP_IN_IRQ, &adapter->state)) { if (test_and_set_bit(__VF_MBX_USED, - &adapter->vfinfo[vf].status)) { + &adapter->vfinfo[vf].status)) { adapter->miss_time++; return -1; } @@ -1257,7 +1245,6 @@ int rnp_msg_post_status(struct rnp_adapter *adapter, enum PF_STATUS status) return err; } - void rnp_ping_all_vfs(struct rnp_adapter *adapter) { struct rnp_hw *hw = &adapter->hw; @@ -1304,14 +1291,15 @@ static int rnp_disable_port_vlan(struct rnp_adapter *adapter, int vf) if (adapter->priv_flags & RNP_PRIV_FLAG_SRIOV_VLAN_MODE) { if (hw->ops.set_vf_vlan_mode) { - if (hw->feature_flags & RNP_NET_FEATURE_VF_FIXED) - hw->ops.set_vf_vlan_mode( - hw, adapter->vfinfo[vf].pf_vlan, + if (hw->feature_flags & RNP_NET_FEATURE_VF_FIXED) { + hw->ops.set_vf_vlan_mode(hw, + adapter->vfinfo[vf].pf_vlan, vf + 1, false); - else - hw->ops.set_vf_vlan_mode( - hw, adapter->vfinfo[vf].pf_vlan, + } else { + hw->ops.set_vf_vlan_mode(hw, + adapter->vfinfo[vf].pf_vlan, vf, false); + } } } adapter->vfinfo[vf].pf_vlan = 0; @@ -1337,12 +1325,10 @@ static int rnp_enable_port_vlan(struct rnp_adapter *adapter, int vf, dev_info(&adapter->pdev->dev, "Setting VLAN %d, QOS 0x%x on VF %d\n", vlan, qos, vf); if (test_bit(__RNP_DOWN, &adapter->state)) { - dev_warn( - &adapter->pdev->dev, - "The VF VLAN has been set, but the PF device is not up.\n"); - dev_warn( - &adapter->pdev->dev, - "Bring the PF device up before attempting to use the VF device.\n"); + dev_warn(&adapter->pdev->dev, + "The VF VLAN has been set, but the PF device is not up.\n"); + dev_warn(&adapter->pdev->dev, + "Bring the PF device up before attempting to use the VF device.\n"); } hw->ops.set_vf_vlan_filter(hw, vlan, vf, true, true); @@ -1375,8 +1361,7 @@ int rnp_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, if (vlan_proto != htons(ETH_P_8021Q)) return -EPROTONOSUPPORT; if (vlan || qos) { - /* - * Check if there is already a port VLAN set, if so + /* Check if there is already a port VLAN set, if so * we have to delete the old one first before we * can set the new one. The usage model had * previously assumed the user would delete the @@ -1397,12 +1382,11 @@ int rnp_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, } else { /* if only vf set vlan */ - if ((adapter->vfinfo[vf].pf_vlan == 0) && - (adapter->vfinfo[vf].vf_vlan)) { + if (adapter->vfinfo[vf].pf_vlan == 0 && + adapter->vfinfo[vf].vf_vlan) { dev_err(&adapter->pdev->dev, "pf cannot delete vm vlan(ip link add)\n"); err = -EINVAL; - } /* if not set vlan before, nothing todo */ @@ -1430,7 +1414,6 @@ int rnp_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, return 0; } - int rnp_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting) { struct rnp_adapter *adapter = netdev_priv(netdev); @@ -1448,8 +1431,6 @@ int rnp_ndo_set_vf_trust(struct net_device *netdev, int vf, bool setting) return 0; } - - int rnp_ndo_set_vf_link_state(struct net_device *netdev, int vf, int state) { struct rnp_adapter *adapter = netdev_priv(netdev); @@ -1495,7 +1476,6 @@ int rnp_ndo_set_vf_link_state(struct net_device *netdev, int vf, int state) return ret; } - int rnp_ndo_set_vf_bw(struct net_device *netdev, int vf, int __always_unused min_tx_rate, int max_tx_rate) { @@ -1529,7 +1509,7 @@ int rnp_ndo_set_vf_bw(struct net_device *netdev, int vf, } /* rate limit cannot be less than 10Mbs or greater than link speed */ if (max_tx_rate && - ((max_tx_rate <= 10) || (max_tx_rate > link_speed))) + (max_tx_rate <= 10 || max_tx_rate > link_speed)) return -EINVAL; adapter->vfinfo[vf].tx_rate = max_tx_rate; @@ -1547,7 +1527,7 @@ int rnp_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) { struct rnp_adapter *adapter = netdev_priv(netdev); - if (!is_valid_ether_addr(mac) || (vf >= adapter->num_vfs)) + if (!is_valid_ether_addr(mac) || vf >= adapter->num_vfs) return -EINVAL; adapter->vfinfo[vf].pf_set_mac = true; dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", mac, diff --git a/drivers/net/ethernet/mucse/rnp/rnp_sysfs.c b/drivers/net/ethernet/mucse/rnp/rnp_sysfs.c index 91b1767b3c92..02a53a36e978 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_sysfs.c +++ b/drivers/net/ethernet/mucse/rnp/rnp_sysfs.c @@ -187,7 +187,7 @@ static ssize_t maintain_read(struct file *filp, struct kobject *kobj, struct rnp_adapter *adapter = netdev_priv(netdev); int rbytes = count; - if (adapter->maintain_buf == NULL) + if (!adapter->maintain_buf) return 0; if (off + count > adapter->maintain_buf_len) @@ -266,8 +266,8 @@ static ssize_t maintain_write(struct file *filp, struct kobject *kobj, /* req can't be acces, a copy data for read */ if (reply_bytes > 0) { adapter->maintain_buf_len = reply_bytes; - adapter->maintain_buf = kmalloc( - adapter->maintain_buf_len, GFP_KERNEL); + adapter->maintain_buf = kmalloc(adapter->maintain_buf_len, + GFP_KERNEL); if (!adapter->maintain_buf) { err = -ENOMEM; goto err_quit; @@ -380,13 +380,15 @@ static ssize_t tcp_sync_info_store(struct device *dev, adapter->tcp_sync_queue = tcp_sync_queue; adapter->priv_flags |= RNP_PRIV_FLAG_TCP_SYNC; - if (adapter->priv_flags & RNP_PRIV_FLAG_TCP_SYNC_PRIO) - hw->ops.set_tcp_sync_remapping( - hw, adapter->tcp_sync_queue, true, true); - else - hw->ops.set_tcp_sync_remapping( - hw, adapter->tcp_sync_queue, true, false); - + if (adapter->priv_flags & RNP_PRIV_FLAG_TCP_SYNC_PRIO) { + hw->ops.set_tcp_sync_remapping(hw, + adapter->tcp_sync_queue, + true, true); + } else { + hw->ops.set_tcp_sync_remapping(hw, + adapter->tcp_sync_queue, + true, false); + } } else { adapter->priv_flags &= ~RNP_PRIV_FLAG_TCP_SYNC; @@ -426,7 +428,7 @@ static ssize_t rx_skip_info_store(struct device *dev, if (kstrtou32(buf, 0, &rx_skip_count) != 0) return -EINVAL; - if ((rx_skip_count > 0) && (rx_skip_count < 17)) { + if (rx_skip_count > 0 && rx_skip_count < 17) { adapter->priv_skip_count = rx_skip_count - 1; adapter->priv_flags |= RNP_PRIV_FLAG_RX_SKIP_EN; hw->ops.set_rx_skip(hw, adapter->priv_skip_count, true); @@ -614,7 +616,7 @@ static ssize_t tx_desc_info_store(struct device *dev, } static ssize_t para_info_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { int ret = 0; struct net_device *netdev = to_net_device(dev); @@ -929,9 +931,9 @@ static ssize_t rx_counter_show(struct device *dev, val); val = rd32(hw, RNP_RXTRANS_CODE_ERR_PKTS(port)); - ret += sprintf( - buf + ret, "\t %16s 0x%08x: %d\n", - "code_err:", RNP_RXTRANS_CODE_ERR_PKTS(port), val); + ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", + "code_err:", RNP_RXTRANS_CODE_ERR_PKTS(port), + val); val = rd32(hw, RNP_RXTRANS_CRC_ERR_PKTS(port)); ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", @@ -939,14 +941,14 @@ static ssize_t rx_counter_show(struct device *dev, val); val = rd32(hw, RNP_RXTRANS_SLEN_ERR_PKTS(port)); - ret += sprintf( - buf + ret, "\t %16s 0x%08x: %d\n", - "slen_err:", RNP_RXTRANS_SLEN_ERR_PKTS(port), val); + ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", + "slen_err:", RNP_RXTRANS_SLEN_ERR_PKTS(port), + val); val = rd32(hw, RNP_RXTRANS_GLEN_ERR_PKTS(port)); - ret += sprintf( - buf + ret, "\t %16s 0x%08x: %d\n", - "glen_err:", RNP_RXTRANS_GLEN_ERR_PKTS(port), val); + ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", + "glen_err:", RNP_RXTRANS_GLEN_ERR_PKTS(port), + val); val = rd32(hw, RNP_RXTRANS_IPH_ERR_PKTS(port)); ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", @@ -954,9 +956,9 @@ static ssize_t rx_counter_show(struct device *dev, val); val = rd32(hw, RNP_RXTRANS_CSUM_ERR_PKTS(port)); - ret += sprintf( - buf + ret, "\t %16s 0x%08x: %d\n", - "csum_err:", RNP_RXTRANS_CSUM_ERR_PKTS(port), val); + ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", + "csum_err:", RNP_RXTRANS_CSUM_ERR_PKTS(port), + val); val = rd32(hw, RNP_RXTRANS_LEN_ERR_PKTS(port)); ret += sprintf(buf + ret, "\t %16s 0x%08x: %d\n", @@ -1148,11 +1150,12 @@ static ssize_t active_vid_show(struct device *dev, struct net_device *netdev = to_net_device(dev); struct rnp_adapter *adapter = netdev_priv(netdev); struct rnp_hw *hw = &adapter->hw; - u8 vfnum = hw->max_vfs - 1; //use last-vf's table entry. the las + u8 vfnum = hw->max_vfs - 1; if ((adapter->flags & RNP_FLAG_SRIOV_ENABLED)) { - current_vid = rd32(hw, RNP_DMA_PORT_VEB_VID_TBL( - adapter->port, vfnum)); + current_vid = rd32(hw, + RNP_DMA_PORT_VEB_VID_TBL(adapter->port, + vfnum)); } for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) { @@ -1182,7 +1185,7 @@ static ssize_t active_vid_store(struct device *dev, if (kstrtou16(buf, 0, &vid) != 0) return -EINVAL; - if ((vid < 4096) && test_bit(vid, adapter->active_vlans)) { + if (vid < 4096 && test_bit(vid, adapter->active_vlans)) { if (rd32(hw, RNP_DMA_VERSION) >= 0x20201231) { for (port = 0; port < 4; port++) wr32(hw, @@ -1190,7 +1193,7 @@ static ssize_t active_vid_store(struct device *dev, vid); } else { wr32(hw, RNP_DMA_PORT_VEB_VID_TBL(adapter->port, - vfnum), vid); + vfnum), vid); } err = 0; } @@ -1211,7 +1214,7 @@ static inline int pn_sn_dlen(char *v, int v_len) return len; } -int rnp_mbx_get_pn_sn(struct rnp_hw *hw, char pn[33], char sn[33]) +static int rnp_mbx_get_pn_sn(struct rnp_hw *hw, char pn[33], char sn[33]) { struct maintain_req *req; void *dma_buf = NULL; @@ -1266,7 +1269,7 @@ int rnp_mbx_get_pn_sn(struct rnp_hw *hw, char pn[33], char sn[33]) } static ssize_t own_vpd_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { int ret = 0; struct net_device *netdev = to_net_device(dev); @@ -1276,9 +1279,8 @@ static ssize_t own_vpd_show(struct device *dev, struct device_attribute *attr, rnp_mbx_get_pn_sn(hw, pn, sn); - ret += sprintf( - buf + ret, "Product Name: %s\n", - "Ethernet Controller N10 Series for 10GbE or 40GbE (Dual-port)"); + ret += sprintf(buf + ret, "Product Name: %s\n", + "N10 Series for 10GbE or 40GbE (Dual-port)"); ret += sprintf(buf + ret, "[PN] Part number: %s\n", pn); ret += sprintf(buf + ret, "[SN] Serial number: %s\n", sn); @@ -1328,11 +1330,10 @@ static ssize_t sfp_show(struct device *dev, struct device_attribute *attr, if (rnp_mbx_get_lane_stat(hw) != 0) { ret += sprintf(buf, " IO Error\n"); } else { - ret += sprintf( - buf, - "mod-abs:%d\ntx-fault:%d\ntx-dis:%d\nrx-los:%d\n", - adapter->sfp.mod_abs, adapter->sfp.fault, - adapter->sfp.tx_dis, adapter->sfp.los); + ret += sprintf(buf, + "mod-abs:%d\ntx-fault:%d\ntx-dis:%d\nrx-los:%d\n", + adapter->sfp.mod_abs, adapter->sfp.fault, + adapter->sfp.tx_dis, adapter->sfp.los); } return ret; @@ -1490,7 +1491,7 @@ static DEVICE_ATTR_RW(fec); /* write pcs reg: echo " " > pcs_reg */ /* read pcs reg: echo " " > pcs_reg */ static ssize_t pcs_reg_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) + const char *buf, size_t count) { u32 reg_hi = 0, reg_lo = 0, pcs_base_regs = 0; struct net_device *netdev = to_net_device(dev); @@ -1542,7 +1543,7 @@ static ssize_t pcs_reg_store(struct device *dev, struct device_attribute *attr, break; default: e_err(drv, "Error: Invalid value. input_arg_cnt=%d\n", - input_arg_cnt); + input_arg_cnt); break; } adapter->sysfs_input_arg_cnt = input_arg_cnt; @@ -1551,7 +1552,7 @@ static ssize_t pcs_reg_store(struct device *dev, struct device_attribute *attr, } static ssize_t pcs_reg_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { int ret = 0; struct net_device *netdev = to_net_device(dev); @@ -1572,7 +1573,7 @@ static ssize_t pcs_reg_show(struct device *dev, struct device_attribute *attr, break; default: e_err(drv, "Error: Invalid input_arg_cnt value =%d\n", - adapter->sysfs_input_arg_cnt); + adapter->sysfs_input_arg_cnt); break; } @@ -1592,8 +1593,10 @@ static ssize_t phy_reg_show(struct device *dev, if (hw) { if (adapter->sysfs_is_phy_ext_reg) { - err = rnp_mbx_phy_read( - hw, phy_reg | PHY_EXT_REG_FLAG, &val); + err = rnp_mbx_phy_read(hw, + phy_reg | + PHY_EXT_REG_FLAG, + &val); } else { err = rnp_mbx_phy_read(hw, phy_reg, &val); } @@ -1665,8 +1668,10 @@ static ssize_t phy_reg_store(struct device *dev, if (adapter->sysfs_is_phy_ext_reg) { /* write ext phy reg */ phy_reg = val[1]; - err = rnp_mbx_phy_write( - hw, phy_reg | PHY_EXT_REG_FLAG, val[2]); + err = rnp_mbx_phy_write(hw, + phy_reg | + PHY_EXT_REG_FLAG, + val[2]); } else { return -EINVAL; } @@ -1731,8 +1736,8 @@ static ssize_t autoneg_show(struct device *dev, static DEVICE_ATTR_RW(autoneg); static ssize_t si_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) + struct device_attribute *attr, + const char *buf, size_t count) { int err = -EINVAL; struct net_device *netdev = to_net_device(dev); @@ -1757,14 +1762,13 @@ static ssize_t si_store(struct device *dev, u32 lane2_main, lane2_pre, lane2_post, lane2_boost; u32 lane3_main, lane3_pre, lane3_post, lane3_boost; - cnt = sscanf( - buf, - "%u %u %u %u,%u %u %u %u,%u %u %u %u,%u %u %u %u", - &lane0_main, &lane0_pre, &lane0_post, &lane0_boost, - &lane1_main, &lane1_pre, &lane1_post, &lane1_boost, - &lane2_main, &lane2_pre, &lane2_post, &lane2_boost, - &lane3_main, &lane3_pre, &lane3_post, - &lane3_boost); + cnt = sscanf(buf, + "%u %u %u %u,%u %u %u %u,%u %u %u %u,%u %u %u %u", + &lane0_main, &lane0_pre, &lane0_post, &lane0_boost, + &lane1_main, &lane1_pre, &lane1_post, &lane1_boost, + &lane2_main, &lane2_pre, &lane2_post, &lane2_boost, + &lane3_main, &lane3_pre, &lane3_post, + &lane3_boost); if (cnt != 16) { e_err(drv, "Error: Invalid Input.\n"); e_err(drv, " ,,,\n"); @@ -1791,8 +1795,8 @@ static ssize_t si_store(struct device *dev, ((lane2_boost & 0xf) << 8) | ((lane3_boost & 0xf) << 12); pr_info("%s: main:0x%x pre:0x%x post:0x%x boost:0x%x\n", - adapter->name, si_main, si_pre, si_post, - si_txboost); + adapter->name, si_main, si_pre, si_post, + si_txboost); } else { cnt = sscanf(buf, "%u %u %u %u", &si_main, &si_pre, &si_post, &si_txboost); @@ -1816,7 +1820,7 @@ static ssize_t si_store(struct device *dev, } static ssize_t si_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { int ret = 0, i; struct net_device *netdev = to_net_device(dev); @@ -1828,32 +1832,29 @@ static ssize_t si_show(struct device *dev, } else { if (hw->supported_link & (RNP_LINK_SPEED_40GB_FULL | RNP_LINK_SPEED_25GB_FULL)) { - ret += sprintf( - buf + ret, - "main:0x%08x pre:0x%08x post:0x%08x tx_boost:0x%04x\n\n", - adapter->si.main, adapter->si.pre, - adapter->si.post, adapter->si.tx_boost); + ret += sprintf(buf + ret, + "main:0x%08x pre:0x%08x post:0x%08x tx_boost:0x%04x\n\n", + adapter->si.main, adapter->si.pre, + adapter->si.post, adapter->si.tx_boost); for (i = 0; i < 4; i++) { - ret += sprintf( - buf + ret, - " lane%d main:%u pre:%u post:%u tx_boost:%u\n", - i, - (adapter->si.main >> (i * 8)) & - 0xff, - (adapter->si.pre >> (i * 8)) & - 0xff, - (adapter->si.post >> (i * 8)) & - 0xff, - (adapter->si.tx_boost >> (i * 4)) & - 0xf); + ret += sprintf(buf + ret, + "lane%d main:%u pre:%u post:%u tx_boost:%u\n", + i, + (adapter->si.main >> (i * 8)) & + 0xff, + (adapter->si.pre >> (i * 8)) & + 0xff, + (adapter->si.post >> (i * 8)) & + 0xff, + (adapter->si.tx_boost >> (i * 4)) & + 0xf); } } else { - ret += sprintf( - buf + ret, - "lane:%d main:%u pre:%u post:%u tx_boost:%u\n", - hw->nr_lane, adapter->si.main, - adapter->si.pre, adapter->si.post, - adapter->si.tx_boost & 0xf); + ret += sprintf(buf + ret, + "lane:%d main:%u pre:%u post:%u tx_boost:%u\n", + hw->nr_lane, adapter->si.main, + adapter->si.pre, adapter->si.post, + adapter->si.tx_boost & 0xf); } } @@ -1915,7 +1916,7 @@ static int do_switch_loopback_set(struct rnp_adapter *adapter, int en, struct rnp_hw *hw = &adapter->hw; pr_info("%s: %s %d -> %d en:%d\n", __func__, - netdev_name(adapter->netdev), sport_lane, dport_lane, en); + netdev_name(adapter->netdev), sport_lane, dport_lane, en); if (en) adapter->flags |= RNP_FLAG_SWITCH_LOOPBACK_EN; @@ -1959,7 +1960,7 @@ static ssize_t _switch_loopback(struct rnp_adapter *adapter, strim(name); pr_info("%s: nr_lane:%d peer_lane:%s en:%d\n", __func__, 0, - peer_eth, en); + peer_eth, en); peer_netdev = dev_get_by_name(&init_net, name); if (!peer_netdev) { @@ -1971,13 +1972,12 @@ static ssize_t _switch_loopback(struct rnp_adapter *adapter, if (PCI_SLOT(peer_adapter->pdev->devfn) != PCI_SLOT(adapter->pdev->devfn)) { e_err(drv, "%s %s not in same slot\n", - netdev_name(adapter->netdev), - netdev_name(peer_adapter->netdev)); + netdev_name(adapter->netdev), + netdev_name(peer_adapter->netdev)); dev_put(peer_netdev); return -EINVAL; } - do_switch_loopback_set(adapter, en, 0, rnp_is_pf1(&peer_adapter->hw) ? 4 : 0); do_switch_loopback_set(peer_adapter, en, 0, @@ -1988,6 +1988,7 @@ static ssize_t _switch_loopback(struct rnp_adapter *adapter, return 0; } + static ssize_t switch_loopback_on_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -2057,10 +2058,12 @@ static struct attribute *dev_attrs[] = { &dev_attr_switch_loopback_on.attr, NULL, }; + static struct bin_attribute *dev_bin_attrs[] = { &bin_attr_maintain, NULL, }; + static struct attribute_group dev_attr_grp = { .attrs = dev_attrs, .bin_attrs = dev_bin_attrs, @@ -2069,7 +2072,6 @@ static struct attribute_group dev_attr_grp = { static void rnp_sysfs_del_adapter(struct rnp_adapter __maybe_unused *adapter) { - } /* called from rnp_main.c */ @@ -2096,7 +2098,7 @@ int rnp_sysfs_init(struct rnp_adapter *adapter) return flag; } /* If this method isn't defined we don't support thermals */ - if (adapter->hw.ops.init_thermal_sensor_thresh == NULL) + if (!adapter->hw.ops.init_thermal_sensor_thresh) goto no_thermal; /* Don't create thermal hwmon interface if no sensors present */ @@ -2114,8 +2116,7 @@ int rnp_sysfs_init(struct rnp_adapter *adapter) adapter->rnp_hwmon_buff = rnp_hwmon; for (i = 0; i < RNP_MAX_SENSORS; i++) { - /* - * Only create hwmon sysfs entries for sensors that have + /* Only create hwmon sysfs entries for sensors that have * meaningful data for. */ if (adapter->hw.thermal_sensor_data.sensor[i].location == @@ -2141,8 +2142,10 @@ int rnp_sysfs_init(struct rnp_adapter *adapter) rnp_hwmon->groups[0] = &rnp_hwmon->group; rnp_hwmon->group.attrs = rnp_hwmon->attrs; - hwmon_dev = devm_hwmon_device_register_with_groups( - &adapter->pdev->dev, "rnp", rnp_hwmon, rnp_hwmon->groups); + hwmon_dev = devm_hwmon_device_register_with_groups(&adapter->pdev->dev, + "rnp", + rnp_hwmon, + rnp_hwmon->groups); if (IS_ERR(hwmon_dev)) { rc = PTR_ERR(hwmon_dev); diff --git a/drivers/net/ethernet/mucse/rnp/rnp_type.h b/drivers/net/ethernet/mucse/rnp/rnp_type.h index bdbc8deecf8f..f8b3e865d7ec 100644 --- a/drivers/net/ethernet/mucse/rnp/rnp_type.h +++ b/drivers/net/ethernet/mucse/rnp/rnp_type.h @@ -8,11 +8,11 @@ #include #include -#if IS_ENABLED(CONFIG_MXGBE_FIX_VF_QUEUE) +#if IS_ENABLED(CONFIG_MXGBE_FIX_VF_QUEUE) && !defined(FIX_VF_QUEUE) #define FIX_VF_QUEUE #endif /* IS_ENABLED(CONFIG_MXGBE_FIX_VF_QUEUE) */ -#if IS_ENABLED(CONFIG_MXGBE_FIX_MAC_PADDING) +#if IS_ENABLED(CONFIG_MXGBE_FIX_MAC_PADDING) && !defined(FIX_MAC_PADDING) #define FIX_MAC_PADDING #endif /* IS_ENABLED(CONFIG_MXGBE_FIX_MAC_PADDING) */ @@ -40,12 +40,6 @@ #define FT_PADDING #endif /* IS_ENABLED(CONFIG_FT_PADDING) */ -// maybe euler can close this ? -//#if IS_ENABLED(CONFIG_ARM64) -//#define NO_BQL_TEST -//#endif - - #if (PAGE_SIZE < 8192) /* if page_size is 4k, no need use this */ #ifdef OPTM_WITH_LARGE @@ -219,11 +213,11 @@ struct rnp_tx_desc { struct rnp_tx_ctx_desc { __le32 mss_len_vf_num; __le32 inner_vlan_tunnel_len; -#define VF_VEB_MARK (1 << 24) /* bit 56 */ -#define VF_VEB_IGNORE_VLAN (1 << 25) /* bit 57 */ +#define VF_VEB_MARK (0x1 << 24) /* bit 56 */ +#define VF_VEB_IGNORE_VLAN (0x1 << 25) /* bit 57 */ __le32 resv; __le32 resv_cmd; -#define RNP_TXD_FLAG_TO_RPU (1 << 15) +#define RNP_TXD_FLAG_TO_RPU (0x1 << 15) #define RNP_TXD_SMAC_CTRL_NOP (0x00 << 12) #define RNP_TXD_SMAC_CTRL_REPLACE_MACADDR0 (0x02 << 12) #define RNP_TXD_SMAC_CTRL_REPLACE_MACADDR1 (0x06 << 12) @@ -254,15 +248,15 @@ union rnp_rx_desc { __le32 rss_hash; __le16 mark; __le16 rev1; -#define RNP_RX_L3_TYPE_MASK (1 << 15) /* 1 is ipv4 */ -#define VEB_VF_PKG (1 << 0) /* bit 48 */ -#define VEB_VF_IGNORE_VLAN (1 << 1) /* bit 49 */ -#define REV_OUTER_VLAN (1 << 5) +#define RNP_RX_L3_TYPE_MASK (0x1 << 15) /* 1 is ipv4 */ +#define VEB_VF_PKG (0x1 << 0) /* bit 48 */ +#define VEB_VF_IGNORE_VLAN (0x1 << 1) /* bit 49 */ +#define REV_OUTER_VLAN (0x1 << 5) __le16 len; __le16 padding_len; __le16 vlan; __le16 cmd; -#define RNP_RXD_STAT_VLAN_VALID (1 << 15) +#define RNP_RXD_STAT_VLAN_VALID (0x1 << 15) #define RNP_RXD_STAT_STAG (0x01 << 14) #define RNP_RXD_STAT_TUNNEL_NVGRE (0x02 << 13) #define RNP_RXD_STAT_TUNNEL_VXLAN (0x01 << 13) @@ -273,11 +267,11 @@ union rnp_rx_desc { #define RNP_RXD_STAT_L4_SCTP (0x02 << 6) #define RNP_RXD_STAT_L4_TCP (0x01 << 6) #define RNP_RXD_STAT_L4_UDP (0x03 << 6) -#define RNP_RXD_STAT_IPV6 (1 << 5) -#define RNP_RXD_STAT_IPV4 (0 << 5) -#define RNP_RXD_STAT_PTP (1 << 4) -#define RNP_RXD_STAT_DD (1 << 1) -#define RNP_RXD_STAT_EOP (1 << 0) +#define RNP_RXD_STAT_IPV6 (0x1 << 5) +#define RNP_RXD_STAT_IPV4 (0x0 << 5) +#define RNP_RXD_STAT_PTP (0x1 << 4) +#define RNP_RXD_STAT_DD (0x1 << 1) +#define RNP_RXD_STAT_EOP (0x1 << 0) } wb; } __packed; @@ -386,8 +380,7 @@ enum { /* Flow Director ATR input struct. */ union rnp_atr_input { - /* - * Byte layout in order, all values with MSB first: + /* Byte layout in order, all values with MSB first: * * vm_pool - 1 byte * flow_type - 1 byte @@ -433,8 +426,8 @@ union rnp_atr_input { }; /* BitTimes (BT) conversion */ -#define RNP_BT2KB(BT) ((BT + (8 * 1024 - 1)) / (8 * 1024)) -#define RNP_B2BT(BT) (BT * 8) +#define RNP_BT2KB(BT) (((BT) + (8 * 1024 - 1)) / (8 * 1024)) +#define RNP_B2BT(BT) ((BT) * 8) /* Calculate Delay to respond to PFC */ #define RNP_PFC_D 672 @@ -661,6 +654,7 @@ struct rnp_hw_stats { /* === mac rx === */ u64 mac_rx_broadcast; u64 mac_rx_multicast; + u64 mac_rx_csum_err; u64 tx_broadcast; u64 tx_multicast; @@ -684,24 +678,23 @@ struct rnp_mac_info; typedef u8 *(*rnp_mc_addr_itr)(struct rnp_hw *hw, u8 **mc_addr_ptr, u32 *vmdq); - /* add nic operations */ struct rnp_eth_operations { /* RAR, Multicast, VLAN */ s32 (*get_mac_addr)(struct rnp_eth_info *eth, u8 *addr); s32 (*set_rar)(struct rnp_eth_info *eth, u32 index, u8 *addr, - bool enable_addr); + bool enable_addr); s32 (*clear_rar)(struct rnp_eth_info *eth, u32 index); s32 (*set_vmdq)(struct rnp_eth_info *eth, u32 rar, u32 vmdq); s32 (*clear_vmdq)(struct rnp_eth_info *eth, u32 rar, u32 vmdq); s32 (*update_mc_addr_list)(struct rnp_eth_info *eth, - struct net_device *netdev, bool sriov_on); + struct net_device *netdev, bool sriov_on); void (*clr_mc_addr)(struct rnp_eth_info *eth); int (*set_rss_hfunc)(struct rnp_eth_info *eth, int hfunc); void (*set_rss_key)(struct rnp_eth_info *eth, bool sriov_en); void (*set_rss_table)(struct rnp_eth_info *eth); void (*set_rx_hash)(struct rnp_eth_info *eth, bool status, - bool sriov_en); + bool sriov_en); s32 (*set_vfta)(struct rnp_eth_info *eth, u32 vlan, bool en); void (*clr_vfta)(struct rnp_eth_info *eth); void (*set_vlan_filter)(struct rnp_eth_info *eth, bool status); @@ -721,10 +714,10 @@ struct rnp_eth_operations { void (*clr_tuple5_remapping)(struct rnp_eth_info *eth, u16 pri_id); void (*clr_all_tuple5_remapping)(struct rnp_eth_info *eth); void (*set_tcp_sync_remapping)(struct rnp_eth_info *eth, int queue, - bool flag, bool prio); + bool flag, bool prio); void (*set_rx_skip)(struct rnp_eth_info *eth, int count, bool flag); void (*set_min_max_packet)(struct rnp_eth_info *eth, int min, - int max); + int max); void (*set_vlan_strip)(struct rnp_eth_info *eth, u16 queue, bool en); void (*set_outer_vlan_type)(struct rnp_eth_info *eth, int type); void (*set_double_vlan)(struct rnp_eth_info *eth, bool en); @@ -734,7 +727,7 @@ struct rnp_eth_operations { void (*set_rx)(struct rnp_eth_info *eth, bool status); void (*set_fcs)(struct rnp_eth_info *eth, bool status); void (*set_vf_vlan_mode)(struct rnp_eth_info *eth, u16 vlan, - int vf, bool enable); + int vf, bool enable); }; enum { @@ -749,16 +742,16 @@ struct rnp_hw_operations { void (*set_mtu)(struct rnp_hw *hw, int new_mtu); void (*set_vlan_filter_en)(struct rnp_hw *hw, bool status); void (*set_vlan_filter)(struct rnp_hw *hw, u16 vid, - bool enable, bool sriov_flag); + bool enable, bool sriov_flag); void (*set_vf_vlan_filter)(struct rnp_hw *hw, u16 vid, int vf, - bool enable, bool veb_only); + bool enable, bool veb_only); void (*clr_vfta)(struct rnp_hw *hw); void (*set_vlan_strip)(struct rnp_hw *hw, u16 queue, bool strip); void (*set_mac)(struct rnp_hw *hw, u8 *mac, bool sriov_flag); void (*set_rx_mode)(struct rnp_hw *hw, struct net_device *netdev, bool sriov_flag); void (*set_rar_with_vf)(struct rnp_hw *hw, u8 *mac, int idx, - u32 vfnum, bool enable); + u32 vfnum, bool enable); void (*clr_rar)(struct rnp_hw *hw, int idx); void (*clr_rar_all)(struct rnp_hw *hw); void (*clr_vlan_veb)(struct rnp_hw *hw); @@ -767,7 +760,7 @@ struct rnp_hw_operations { void (*set_vxlan_port)(struct rnp_hw *hw, u32 port); void (*set_vxlan_mode)(struct rnp_hw *hw, bool innel); void (*set_mac_speed)(struct rnp_hw *hw, bool link, - u32 speed, bool duplex); + u32 speed, bool duplex); void (*set_mac_rx)(struct rnp_hw *hw, bool status); void (*update_sriov_info)(struct rnp_hw *hw); void (*set_sriov_status)(struct rnp_hw *hw, bool status); @@ -787,9 +780,9 @@ struct rnp_hw_operations { void (*enable_tx_laser)(struct rnp_hw *hw); void (*flap_tx_laser)(struct rnp_hw *hw); s32 (*check_link)(struct rnp_hw *hw, rnp_link_speed *speed, - bool *link_up, bool *duplex, bool wait_en); + bool *link_up, bool *duplex, bool wait_en); s32 (*setup_link)(struct rnp_hw *hw, u32 adv, - u32 autoneg, u32 speed, u32 duplex); + u32 autoneg, u32 speed, u32 duplex); void (*clean_link)(struct rnp_hw *hw); s32 (*get_link_capabilities)(struct rnp_hw *hw, rnp_link_speed *speed, bool *autoneg); @@ -818,18 +811,18 @@ struct rnp_hw_operations { s32 (*phy_write_reg)(struct rnp_hw *hw, u32 addr, u32 type, u16 data); void (*setup_wol)(struct rnp_hw *hw, u32 mode); void (*set_vf_vlan_mode)(struct rnp_hw *hw, u16 vlan, int vf, - bool en); - void (*driver_status)(struct rnp_hw *hw, bool eanble, int mode); + bool en); + void (*driver_status)(struct rnp_hw *hw, bool enable, int mode); }; struct rnp_mac_operations { void (*set_mac_rx)(struct rnp_mac_info *mac, bool status); void (*set_mac_speed)(struct rnp_mac_info *mac, bool link, - u32 speed, bool duplex); + u32 speed, bool duplex); void (*set_mac_fcs)(struct rnp_mac_info *mac, bool status); s32 (*set_fc_mode)(struct rnp_mac_info *mac); void (*check_link)(struct rnp_mac_info *mac, rnp_link_speed *speed, - bool *link_up, bool wait_to_complete); + bool *link_up, bool wait_to_complete); void (*set_mac)(struct rnp_mac_info *mac, u8 *addr, int index); int (*mdio_write)(struct rnp_mac_info *mac, int phyreg, int phydata); int (*mdio_read)(struct rnp_mac_info *mac, int phyreg, int *regvalue); @@ -847,11 +840,11 @@ struct rnp_eeprom_info { struct rnp_dma_operations { void (*set_tx_maxrate)(struct rnp_dma_info *dma, u16 queue, u32 max_rate); void (*set_veb_mac)(struct rnp_dma_info *dma, u8 *mac, u32 vfnum, - u32 ring); + u32 ring); /* only set own vlan */ void (*set_veb_vlan)(struct rnp_dma_info *dma, u16 vlan, u32 vfnum); void (*set_veb_vlan_mask)(struct rnp_dma_info *dma, u16 vid, - u16 vf, int enable); + u16 vf, int enable); void (*clr_veb_all)(struct rnp_dma_info *dma); }; @@ -999,6 +992,7 @@ struct rnp_mbx_info { u16 vf_ack[64]; u16 cpu_req; u16 cpu_ack; + /* mbx lock */ struct mutex lock; bool other_irq_enabled; int mbx_size; diff --git a/drivers/net/ethernet/mucse/rnp/version.h b/drivers/net/ethernet/mucse/rnp/version.h index 8f5b34f48113..a8020b4fdf30 100644 --- a/drivers/net/ethernet/mucse/rnp/version.h +++ b/drivers/net/ethernet/mucse/rnp/version.h @@ -3,5 +3,5 @@ #ifndef VERSION_H #define VERSION_H -#define GIT_COMMIT " e661fce" +#define GIT_COMMIT " 8206c05" #endif -- Gitee