diff options
author | Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> | 2018-09-19 20:23:04 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2018-10-01 15:39:40 -0400 |
commit | 45d3d428eafcbb18027c419624ce950b4db3a4b4 (patch) | |
tree | c33223eb6b3dca3b909a32fc09b284a0eee61ba4 /drivers/net/ethernet/intel/ice/ice_common.c | |
parent | 3b6bf296c44f2b1233b7622c847a6ac5b1aeba0f (diff) |
ice: Move common functions out of ice_main.c part 1/7
The functions that are used for PF VSI/netdev setup will also be used
for SR-IOV support. To allow reuse of these functions, move these
functions out of ice_main.c to ice_common.c/ice_lib.c
This move is done across multiple patches. Each patch moves a few
functions and may have minor adjustments. For example, a function that was
previously static in ice_main.c will be made non-static temporarily in
its new location to allow the driver to build cleanly. These adjustments
will be removed in subsequent patches where more code is moved out of
ice_main.c
In this particular patch, the following functions were moved out of
ice_main.c:
int ice_add_mac_to_list
ice_free_fltr_list
ice_stat_update40
ice_stat_update32
ice_update_eth_stats
ice_vsi_add_vlan
ice_vsi_kill_vlan
ice_vsi_manage_vlan_insertion
ice_vsi_manage_vlan_stripping
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/ice/ice_common.c')
-rw-r--r-- | drivers/net/ethernet/intel/ice/ice_common.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c index decfdb065a20..ef9229fa5510 100644 --- a/drivers/net/ethernet/intel/ice/ice_common.c +++ b/drivers/net/ethernet/intel/ice/ice_common.c | |||
@@ -2652,3 +2652,64 @@ ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_id, u8 tc_bitmap, | |||
2652 | return ice_cfg_vsi_qs(pi, vsi_id, tc_bitmap, max_lanqs, | 2652 | return ice_cfg_vsi_qs(pi, vsi_id, tc_bitmap, max_lanqs, |
2653 | ICE_SCHED_NODE_OWNER_LAN); | 2653 | ICE_SCHED_NODE_OWNER_LAN); |
2654 | } | 2654 | } |
2655 | |||
2656 | /** | ||
2657 | * ice_stat_update40 - read 40 bit stat from the chip and update stat values | ||
2658 | * @hw: ptr to the hardware info | ||
2659 | * @hireg: high 32 bit HW register to read from | ||
2660 | * @loreg: low 32 bit HW register to read from | ||
2661 | * @prev_stat_loaded: bool to specify if previous stats are loaded | ||
2662 | * @prev_stat: ptr to previous loaded stat value | ||
2663 | * @cur_stat: ptr to current stat value | ||
2664 | */ | ||
2665 | void ice_stat_update40(struct ice_hw *hw, u32 hireg, u32 loreg, | ||
2666 | bool prev_stat_loaded, u64 *prev_stat, u64 *cur_stat) | ||
2667 | { | ||
2668 | u64 new_data; | ||
2669 | |||
2670 | new_data = rd32(hw, loreg); | ||
2671 | new_data |= ((u64)(rd32(hw, hireg) & 0xFFFF)) << 32; | ||
2672 | |||
2673 | /* device stats are not reset at PFR, they likely will not be zeroed | ||
2674 | * when the driver starts. So save the first values read and use them as | ||
2675 | * offsets to be subtracted from the raw values in order to report stats | ||
2676 | * that count from zero. | ||
2677 | */ | ||
2678 | if (!prev_stat_loaded) | ||
2679 | *prev_stat = new_data; | ||
2680 | if (new_data >= *prev_stat) | ||
2681 | *cur_stat = new_data - *prev_stat; | ||
2682 | else | ||
2683 | /* to manage the potential roll-over */ | ||
2684 | *cur_stat = (new_data + BIT_ULL(40)) - *prev_stat; | ||
2685 | *cur_stat &= 0xFFFFFFFFFFULL; | ||
2686 | } | ||
2687 | |||
2688 | /** | ||
2689 | * ice_stat_update32 - read 32 bit stat from the chip and update stat values | ||
2690 | * @hw: ptr to the hardware info | ||
2691 | * @reg: HW register to read from | ||
2692 | * @prev_stat_loaded: bool to specify if previous stats are loaded | ||
2693 | * @prev_stat: ptr to previous loaded stat value | ||
2694 | * @cur_stat: ptr to current stat value | ||
2695 | */ | ||
2696 | void ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, | ||
2697 | u64 *prev_stat, u64 *cur_stat) | ||
2698 | { | ||
2699 | u32 new_data; | ||
2700 | |||
2701 | new_data = rd32(hw, reg); | ||
2702 | |||
2703 | /* device stats are not reset at PFR, they likely will not be zeroed | ||
2704 | * when the driver starts. So save the first values read and use them as | ||
2705 | * offsets to be subtracted from the raw values in order to report stats | ||
2706 | * that count from zero. | ||
2707 | */ | ||
2708 | if (!prev_stat_loaded) | ||
2709 | *prev_stat = new_data; | ||
2710 | if (new_data >= *prev_stat) | ||
2711 | *cur_stat = new_data - *prev_stat; | ||
2712 | else | ||
2713 | /* to manage the potential roll-over */ | ||
2714 | *cur_stat = (new_data + BIT_ULL(32)) - *prev_stat; | ||
2715 | } | ||