diff options
| author | Sathya Perla <sathya.perla@emulex.com> | 2015-02-06 08:18:35 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-02-08 01:50:57 -0500 |
| commit | f7062ee5e44a044da41cdae8370368314103a930 (patch) | |
| tree | fd7983d7a5b9d9d7387cc719a04ae3afa2a55e51 | |
| parent | 1fd0bddb618aa970b87e7907a5703682aa119a6f (diff) | |
be2net: move un-exported routines from be.h to respective src files
Routines that are called only inside one src file must remain in that
file itself. Including them in a header file that is used for exporting
routine/struct definitions, causes unnecessary compilation of other
src files, when such a routine is modified.
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/emulex/benet/be.h | 166 | ||||
| -rw-r--r-- | drivers/net/ethernet/emulex/benet/be_cmds.c | 18 | ||||
| -rw-r--r-- | drivers/net/ethernet/emulex/benet/be_main.c | 149 |
3 files changed, 167 insertions, 166 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 9fa2569f56cb..3b1d59d1bd1c 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
| @@ -59,26 +59,6 @@ | |||
| 59 | #define OC_SUBSYS_DEVICE_ID3 0xE612 | 59 | #define OC_SUBSYS_DEVICE_ID3 0xE612 |
| 60 | #define OC_SUBSYS_DEVICE_ID4 0xE652 | 60 | #define OC_SUBSYS_DEVICE_ID4 0xE652 |
| 61 | 61 | ||
| 62 | static inline char *nic_name(struct pci_dev *pdev) | ||
| 63 | { | ||
| 64 | switch (pdev->device) { | ||
| 65 | case OC_DEVICE_ID1: | ||
| 66 | return OC_NAME; | ||
| 67 | case OC_DEVICE_ID2: | ||
| 68 | return OC_NAME_BE; | ||
| 69 | case OC_DEVICE_ID3: | ||
| 70 | case OC_DEVICE_ID4: | ||
| 71 | return OC_NAME_LANCER; | ||
| 72 | case BE_DEVICE_ID2: | ||
| 73 | return BE3_NAME; | ||
| 74 | case OC_DEVICE_ID5: | ||
| 75 | case OC_DEVICE_ID6: | ||
| 76 | return OC_NAME_SH; | ||
| 77 | default: | ||
| 78 | return BE_NAME; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | /* Number of bytes of an RX frame that are copied to skb->data */ | 62 | /* Number of bytes of an RX frame that are copied to skb->data */ |
| 83 | #define BE_HDR_LEN ((u16) 64) | 63 | #define BE_HDR_LEN ((u16) 64) |
| 84 | /* allocate extra space to allow tunneling decapsulation without head reallocation */ | 64 | /* allocate extra space to allow tunneling decapsulation without head reallocation */ |
| @@ -734,19 +714,6 @@ static inline bool is_ipv4_pkt(struct sk_buff *skb) | |||
| 734 | return skb->protocol == htons(ETH_P_IP) && ip_hdr(skb)->version == 4; | 714 | return skb->protocol == htons(ETH_P_IP) && ip_hdr(skb)->version == 4; |
| 735 | } | 715 | } |
| 736 | 716 | ||
| 737 | static inline void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac) | ||
| 738 | { | ||
| 739 | u32 addr; | ||
| 740 | |||
| 741 | addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0); | ||
| 742 | |||
| 743 | mac[5] = (u8)(addr & 0xFF); | ||
| 744 | mac[4] = (u8)((addr >> 8) & 0xFF); | ||
| 745 | mac[3] = (u8)((addr >> 16) & 0xFF); | ||
| 746 | /* Use the OUI from the current MAC address */ | ||
| 747 | memcpy(mac, adapter->netdev->dev_addr, 3); | ||
| 748 | } | ||
| 749 | |||
| 750 | static inline bool be_multi_rxq(const struct be_adapter *adapter) | 717 | static inline bool be_multi_rxq(const struct be_adapter *adapter) |
| 751 | { | 718 | { |
| 752 | return adapter->num_rx_qs > 1; | 719 | return adapter->num_rx_qs > 1; |
| @@ -769,129 +736,6 @@ static inline void be_clear_all_error(struct be_adapter *adapter) | |||
| 769 | adapter->fw_timeout = false; | 736 | adapter->fw_timeout = false; |
| 770 | } | 737 | } |
| 771 | 738 | ||
| 772 | static inline bool be_is_wol_excluded(struct be_adapter *adapter) | ||
| 773 | { | ||
| 774 | struct pci_dev *pdev = adapter->pdev; | ||
| 775 | |||
| 776 | if (!be_physfn(adapter)) | ||
| 777 | return true; | ||
| 778 | |||
| 779 | switch (pdev->subsystem_device) { | ||
| 780 | case OC_SUBSYS_DEVICE_ID1: | ||
| 781 | case OC_SUBSYS_DEVICE_ID2: | ||
| 782 | case OC_SUBSYS_DEVICE_ID3: | ||
| 783 | case OC_SUBSYS_DEVICE_ID4: | ||
| 784 | return true; | ||
| 785 | default: | ||
| 786 | return false; | ||
| 787 | } | ||
| 788 | } | ||
| 789 | |||
| 790 | static inline int qnq_async_evt_rcvd(struct be_adapter *adapter) | ||
| 791 | { | ||
| 792 | return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; | ||
| 793 | } | ||
| 794 | |||
| 795 | #ifdef CONFIG_NET_RX_BUSY_POLL | ||
| 796 | static inline bool be_lock_napi(struct be_eq_obj *eqo) | ||
| 797 | { | ||
| 798 | bool status = true; | ||
| 799 | |||
| 800 | spin_lock(&eqo->lock); /* BH is already disabled */ | ||
| 801 | if (eqo->state & BE_EQ_LOCKED) { | ||
| 802 | WARN_ON(eqo->state & BE_EQ_NAPI); | ||
| 803 | eqo->state |= BE_EQ_NAPI_YIELD; | ||
| 804 | status = false; | ||
| 805 | } else { | ||
| 806 | eqo->state = BE_EQ_NAPI; | ||
| 807 | } | ||
| 808 | spin_unlock(&eqo->lock); | ||
| 809 | return status; | ||
| 810 | } | ||
| 811 | |||
| 812 | static inline void be_unlock_napi(struct be_eq_obj *eqo) | ||
| 813 | { | ||
| 814 | spin_lock(&eqo->lock); /* BH is already disabled */ | ||
| 815 | |||
| 816 | WARN_ON(eqo->state & (BE_EQ_POLL | BE_EQ_NAPI_YIELD)); | ||
| 817 | eqo->state = BE_EQ_IDLE; | ||
| 818 | |||
| 819 | spin_unlock(&eqo->lock); | ||
| 820 | } | ||
| 821 | |||
| 822 | static inline bool be_lock_busy_poll(struct be_eq_obj *eqo) | ||
| 823 | { | ||
| 824 | bool status = true; | ||
| 825 | |||
| 826 | spin_lock_bh(&eqo->lock); | ||
| 827 | if (eqo->state & BE_EQ_LOCKED) { | ||
| 828 | eqo->state |= BE_EQ_POLL_YIELD; | ||
| 829 | status = false; | ||
| 830 | } else { | ||
| 831 | eqo->state |= BE_EQ_POLL; | ||
| 832 | } | ||
| 833 | spin_unlock_bh(&eqo->lock); | ||
| 834 | return status; | ||
| 835 | } | ||
| 836 | |||
| 837 | static inline void be_unlock_busy_poll(struct be_eq_obj *eqo) | ||
| 838 | { | ||
| 839 | spin_lock_bh(&eqo->lock); | ||
| 840 | |||
| 841 | WARN_ON(eqo->state & (BE_EQ_NAPI)); | ||
| 842 | eqo->state = BE_EQ_IDLE; | ||
| 843 | |||
| 844 | spin_unlock_bh(&eqo->lock); | ||
| 845 | } | ||
| 846 | |||
| 847 | static inline void be_enable_busy_poll(struct be_eq_obj *eqo) | ||
| 848 | { | ||
| 849 | spin_lock_init(&eqo->lock); | ||
| 850 | eqo->state = BE_EQ_IDLE; | ||
| 851 | } | ||
| 852 | |||
| 853 | static inline void be_disable_busy_poll(struct be_eq_obj *eqo) | ||
| 854 | { | ||
| 855 | local_bh_disable(); | ||
| 856 | |||
| 857 | /* It's enough to just acquire napi lock on the eqo to stop | ||
| 858 | * be_busy_poll() from processing any queueus. | ||
| 859 | */ | ||
| 860 | while (!be_lock_napi(eqo)) | ||
| 861 | mdelay(1); | ||
| 862 | |||
| 863 | local_bh_enable(); | ||
| 864 | } | ||
| 865 | |||
| 866 | #else /* CONFIG_NET_RX_BUSY_POLL */ | ||
| 867 | |||
| 868 | static inline bool be_lock_napi(struct be_eq_obj *eqo) | ||
| 869 | { | ||
| 870 | return true; | ||
| 871 | } | ||
| 872 | |||
| 873 | static inline void be_unlock_napi(struct be_eq_obj *eqo) | ||
| 874 | { | ||
| 875 | } | ||
| 876 | |||
| 877 | static inline bool be_lock_busy_poll(struct be_eq_obj *eqo) | ||
| 878 | { | ||
| 879 | return false; | ||
| 880 | } | ||
| 881 | |||
| 882 | static inline void be_unlock_busy_poll(struct be_eq_obj *eqo) | ||
| 883 | { | ||
| 884 | } | ||
| 885 | |||
| 886 | static inline void be_enable_busy_poll(struct be_eq_obj *eqo) | ||
| 887 | { | ||
| 888 | } | ||
| 889 | |||
| 890 | static inline void be_disable_busy_poll(struct be_eq_obj *eqo) | ||
| 891 | { | ||
| 892 | } | ||
| 893 | #endif /* CONFIG_NET_RX_BUSY_POLL */ | ||
| 894 | |||
| 895 | void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, | 739 | void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, |
| 896 | u16 num_popped); | 740 | u16 num_popped); |
| 897 | void be_link_status_update(struct be_adapter *adapter, u8 link_status); | 741 | void be_link_status_update(struct be_adapter *adapter, u8 link_status); |
| @@ -900,16 +744,6 @@ int be_load_fw(struct be_adapter *adapter, u8 *func); | |||
| 900 | bool be_is_wol_supported(struct be_adapter *adapter); | 744 | bool be_is_wol_supported(struct be_adapter *adapter); |
| 901 | bool be_pause_supported(struct be_adapter *adapter); | 745 | bool be_pause_supported(struct be_adapter *adapter); |
| 902 | u32 be_get_fw_log_level(struct be_adapter *adapter); | 746 | u32 be_get_fw_log_level(struct be_adapter *adapter); |
| 903 | |||
| 904 | static inline int fw_major_num(const char *fw_ver) | ||
| 905 | { | ||
| 906 | int fw_major = 0; | ||
| 907 | |||
| 908 | sscanf(fw_ver, "%d.", &fw_major); | ||
| 909 | |||
| 910 | return fw_major; | ||
| 911 | } | ||
| 912 | |||
| 913 | int be_update_queues(struct be_adapter *adapter); | 747 | int be_update_queues(struct be_adapter *adapter); |
| 914 | int be_poll(struct napi_struct *napi, int budget); | 748 | int be_poll(struct napi_struct *napi, int budget); |
| 915 | 749 | ||
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c index b5aa77284508..6830bffa4eee 100644 --- a/drivers/net/ethernet/emulex/benet/be_cmds.c +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c | |||
| @@ -3241,6 +3241,24 @@ err: | |||
| 3241 | return status; | 3241 | return status; |
| 3242 | } | 3242 | } |
| 3243 | 3243 | ||
| 3244 | static bool be_is_wol_excluded(struct be_adapter *adapter) | ||
| 3245 | { | ||
| 3246 | struct pci_dev *pdev = adapter->pdev; | ||
| 3247 | |||
| 3248 | if (!be_physfn(adapter)) | ||
| 3249 | return true; | ||
| 3250 | |||
| 3251 | switch (pdev->subsystem_device) { | ||
| 3252 | case OC_SUBSYS_DEVICE_ID1: | ||
| 3253 | case OC_SUBSYS_DEVICE_ID2: | ||
| 3254 | case OC_SUBSYS_DEVICE_ID3: | ||
| 3255 | case OC_SUBSYS_DEVICE_ID4: | ||
| 3256 | return true; | ||
| 3257 | default: | ||
| 3258 | return false; | ||
| 3259 | } | ||
| 3260 | } | ||
| 3261 | |||
| 3244 | int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) | 3262 | int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter) |
| 3245 | { | 3263 | { |
| 3246 | struct be_mcc_wrb *wrb; | 3264 | struct be_mcc_wrb *wrb; |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index efed92c7b731..1605bd7a0749 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
| @@ -854,6 +854,11 @@ dma_err: | |||
| 854 | return 0; | 854 | return 0; |
| 855 | } | 855 | } |
| 856 | 856 | ||
| 857 | static inline int qnq_async_evt_rcvd(struct be_adapter *adapter) | ||
| 858 | { | ||
| 859 | return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; | ||
| 860 | } | ||
| 861 | |||
| 857 | static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter, | 862 | static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter, |
| 858 | struct sk_buff *skb, | 863 | struct sk_buff *skb, |
| 859 | bool *skip_hw_vlan) | 864 | bool *skip_hw_vlan) |
| @@ -2526,6 +2531,106 @@ static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo, | |||
| 2526 | } | 2531 | } |
| 2527 | } | 2532 | } |
| 2528 | 2533 | ||
| 2534 | #ifdef CONFIG_NET_RX_BUSY_POLL | ||
| 2535 | static inline bool be_lock_napi(struct be_eq_obj *eqo) | ||
| 2536 | { | ||
| 2537 | bool status = true; | ||
| 2538 | |||
| 2539 | spin_lock(&eqo->lock); /* BH is already disabled */ | ||
| 2540 | if (eqo->state & BE_EQ_LOCKED) { | ||
| 2541 | WARN_ON(eqo->state & BE_EQ_NAPI); | ||
| 2542 | eqo->state |= BE_EQ_NAPI_YIELD; | ||
| 2543 | status = false; | ||
| 2544 | } else { | ||
| 2545 | eqo->state = BE_EQ_NAPI; | ||
| 2546 | } | ||
| 2547 | spin_unlock(&eqo->lock); | ||
| 2548 | return status; | ||
| 2549 | } | ||
| 2550 | |||
| 2551 | static inline void be_unlock_napi(struct be_eq_obj *eqo) | ||
| 2552 | { | ||
| 2553 | spin_lock(&eqo->lock); /* BH is already disabled */ | ||
| 2554 | |||
| 2555 | WARN_ON(eqo->state & (BE_EQ_POLL | BE_EQ_NAPI_YIELD)); | ||
| 2556 | eqo->state = BE_EQ_IDLE; | ||
| 2557 | |||
| 2558 | spin_unlock(&eqo->lock); | ||
| 2559 | } | ||
| 2560 | |||
| 2561 | static inline bool be_lock_busy_poll(struct be_eq_obj *eqo) | ||
| 2562 | { | ||
| 2563 | bool status = true; | ||
| 2564 | |||
| 2565 | spin_lock_bh(&eqo->lock); | ||
| 2566 | if (eqo->state & BE_EQ_LOCKED) { | ||
| 2567 | eqo->state |= BE_EQ_POLL_YIELD; | ||
| 2568 | status = false; | ||
| 2569 | } else { | ||
| 2570 | eqo->state |= BE_EQ_POLL; | ||
| 2571 | } | ||
| 2572 | spin_unlock_bh(&eqo->lock); | ||
| 2573 | return status; | ||
| 2574 | } | ||
| 2575 | |||
| 2576 | static inline void be_unlock_busy_poll(struct be_eq_obj *eqo) | ||
| 2577 | { | ||
| 2578 | spin_lock_bh(&eqo->lock); | ||
| 2579 | |||
| 2580 | WARN_ON(eqo->state & (BE_EQ_NAPI)); | ||
| 2581 | eqo->state = BE_EQ_IDLE; | ||
| 2582 | |||
| 2583 | spin_unlock_bh(&eqo->lock); | ||
| 2584 | } | ||
| 2585 | |||
| 2586 | static inline void be_enable_busy_poll(struct be_eq_obj *eqo) | ||
| 2587 | { | ||
| 2588 | spin_lock_init(&eqo->lock); | ||
| 2589 | eqo->state = BE_EQ_IDLE; | ||
| 2590 | } | ||
| 2591 | |||
| 2592 | static inline void be_disable_busy_poll(struct be_eq_obj *eqo) | ||
| 2593 | { | ||
| 2594 | local_bh_disable(); | ||
| 2595 | |||
| 2596 | /* It's enough to just acquire napi lock on the eqo to stop | ||
| 2597 | * be_busy_poll() from processing any queueus. | ||
| 2598 | */ | ||
| 2599 | while (!be_lock_napi(eqo)) | ||
| 2600 | mdelay(1); | ||
| 2601 | |||
| 2602 | local_bh_enable(); | ||
| 2603 | } | ||
| 2604 | |||
| 2605 | #else /* CONFIG_NET_RX_BUSY_POLL */ | ||
| 2606 | |||
| 2607 | static inline bool be_lock_napi(struct be_eq_obj *eqo) | ||
| 2608 | { | ||
| 2609 | return true; | ||
| 2610 | } | ||
| 2611 | |||
| 2612 | static inline void be_unlock_napi(struct be_eq_obj *eqo) | ||
| 2613 | { | ||
| 2614 | } | ||
| 2615 | |||
| 2616 | static inline bool be_lock_busy_poll(struct be_eq_obj *eqo) | ||
| 2617 | { | ||
| 2618 | return false; | ||
| 2619 | } | ||
| 2620 | |||
| 2621 | static inline void be_unlock_busy_poll(struct be_eq_obj *eqo) | ||
| 2622 | { | ||
| 2623 | } | ||
| 2624 | |||
| 2625 | static inline void be_enable_busy_poll(struct be_eq_obj *eqo) | ||
| 2626 | { | ||
| 2627 | } | ||
| 2628 | |||
| 2629 | static inline void be_disable_busy_poll(struct be_eq_obj *eqo) | ||
| 2630 | { | ||
| 2631 | } | ||
| 2632 | #endif /* CONFIG_NET_RX_BUSY_POLL */ | ||
| 2633 | |||
| 2529 | int be_poll(struct napi_struct *napi, int budget) | 2634 | int be_poll(struct napi_struct *napi, int budget) |
| 2530 | { | 2635 | { |
| 2531 | struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi); | 2636 | struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi); |
| @@ -3020,6 +3125,19 @@ static int be_setup_wol(struct be_adapter *adapter, bool enable) | |||
| 3020 | return status; | 3125 | return status; |
| 3021 | } | 3126 | } |
| 3022 | 3127 | ||
| 3128 | static void be_vf_eth_addr_generate(struct be_adapter *adapter, u8 *mac) | ||
| 3129 | { | ||
| 3130 | u32 addr; | ||
| 3131 | |||
| 3132 | addr = jhash(adapter->netdev->dev_addr, ETH_ALEN, 0); | ||
| 3133 | |||
| 3134 | mac[5] = (u8)(addr & 0xFF); | ||
| 3135 | mac[4] = (u8)((addr >> 8) & 0xFF); | ||
| 3136 | mac[3] = (u8)((addr >> 16) & 0xFF); | ||
| 3137 | /* Use the OUI from the current MAC address */ | ||
| 3138 | memcpy(mac, adapter->netdev->dev_addr, 3); | ||
| 3139 | } | ||
| 3140 | |||
| 3023 | /* | 3141 | /* |
| 3024 | * Generate a seed MAC address from the PF MAC Address using jhash. | 3142 | * Generate a seed MAC address from the PF MAC Address using jhash. |
| 3025 | * MAC Address for VFs are assigned incrementally starting from the seed. | 3143 | * MAC Address for VFs are assigned incrementally starting from the seed. |
| @@ -3664,6 +3782,17 @@ int be_update_queues(struct be_adapter *adapter) | |||
| 3664 | return status; | 3782 | return status; |
| 3665 | } | 3783 | } |
| 3666 | 3784 | ||
| 3785 | static inline int fw_major_num(const char *fw_ver) | ||
| 3786 | { | ||
| 3787 | int fw_major = 0, i; | ||
| 3788 | |||
| 3789 | i = sscanf(fw_ver, "%d.", &fw_major); | ||
| 3790 | if (i != 1) | ||
| 3791 | return 0; | ||
| 3792 | |||
| 3793 | return fw_major; | ||
| 3794 | } | ||
| 3795 | |||
| 3667 | static int be_setup(struct be_adapter *adapter) | 3796 | static int be_setup(struct be_adapter *adapter) |
| 3668 | { | 3797 | { |
| 3669 | struct device *dev = &adapter->pdev->dev; | 3798 | struct device *dev = &adapter->pdev->dev; |
| @@ -4940,6 +5069,26 @@ static inline char *func_name(struct be_adapter *adapter) | |||
| 4940 | return be_physfn(adapter) ? "PF" : "VF"; | 5069 | return be_physfn(adapter) ? "PF" : "VF"; |
| 4941 | } | 5070 | } |
| 4942 | 5071 | ||
| 5072 | static inline char *nic_name(struct pci_dev *pdev) | ||
| 5073 | { | ||
| 5074 | switch (pdev->device) { | ||
| 5075 | case OC_DEVICE_ID1: | ||
| 5076 | return OC_NAME; | ||
| 5077 | case OC_DEVICE_ID2: | ||
| 5078 | return OC_NAME_BE; | ||
| 5079 | case OC_DEVICE_ID3: | ||
| 5080 | case OC_DEVICE_ID4: | ||
| 5081 | return OC_NAME_LANCER; | ||
| 5082 | case BE_DEVICE_ID2: | ||
| 5083 | return BE3_NAME; | ||
| 5084 | case OC_DEVICE_ID5: | ||
| 5085 | case OC_DEVICE_ID6: | ||
| 5086 | return OC_NAME_SH; | ||
| 5087 | default: | ||
| 5088 | return BE_NAME; | ||
| 5089 | } | ||
| 5090 | } | ||
| 5091 | |||
| 4943 | static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) | 5092 | static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id) |
| 4944 | { | 5093 | { |
| 4945 | int status = 0; | 5094 | int status = 0; |
