aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2011-11-04 01:47:06 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-11-16 07:08:27 -0500
commitef9b965a1c4ebd0f0ee961dbc328e1222dc8f487 (patch)
tree4cd7d702665846830315386bc653cc4226208680 /drivers/net/ethernet
parent229a66e3bec97563aa92e25dfe0bc60b0d468619 (diff)
e1000e: convert to real ndo_set_rx_mode
Commit afc4b13d (net: remove use of ndo_set_multicast_list in drivers) changed e1000e to use the ndo_set_rx_mode entry point, but didn't implement the unicast address programming functionality. Implement it to achieve the ability to add unicast addresses. Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/intel/e1000e/netdev.c158
1 files changed, 114 insertions, 44 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index a855db1ad249..80e69d37b3c7 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -3113,79 +3113,147 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
3113} 3113}
3114 3114
3115/** 3115/**
3116 * e1000_update_mc_addr_list - Update Multicast addresses 3116 * e1000e_write_mc_addr_list - write multicast addresses to MTA
3117 * @hw: pointer to the HW structure 3117 * @netdev: network interface device structure
3118 * @mc_addr_list: array of multicast addresses to program
3119 * @mc_addr_count: number of multicast addresses to program
3120 * 3118 *
3121 * Updates the Multicast Table Array. 3119 * Writes multicast address list to the MTA hash table.
3122 * The caller must have a packed mc_addr_list of multicast addresses. 3120 * Returns: -ENOMEM on failure
3121 * 0 on no addresses written
3122 * X on writing X addresses to MTA
3123 */
3124static int e1000e_write_mc_addr_list(struct net_device *netdev)
3125{
3126 struct e1000_adapter *adapter = netdev_priv(netdev);
3127 struct e1000_hw *hw = &adapter->hw;
3128 struct netdev_hw_addr *ha;
3129 u8 *mta_list;
3130 int i;
3131
3132 if (netdev_mc_empty(netdev)) {
3133 /* nothing to program, so clear mc list */
3134 hw->mac.ops.update_mc_addr_list(hw, NULL, 0);
3135 return 0;
3136 }
3137
3138 mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC);
3139 if (!mta_list)
3140 return -ENOMEM;
3141
3142 /* update_mc_addr_list expects a packed array of only addresses. */
3143 i = 0;
3144 netdev_for_each_mc_addr(ha, netdev)
3145 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
3146
3147 hw->mac.ops.update_mc_addr_list(hw, mta_list, i);
3148 kfree(mta_list);
3149
3150 return netdev_mc_count(netdev);
3151}
3152
3153/**
3154 * e1000e_write_uc_addr_list - write unicast addresses to RAR table
3155 * @netdev: network interface device structure
3156 *
3157 * Writes unicast address list to the RAR table.
3158 * Returns: -ENOMEM on failure/insufficient address space
3159 * 0 on no addresses written
3160 * X on writing X addresses to the RAR table
3123 **/ 3161 **/
3124static void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list, 3162static int e1000e_write_uc_addr_list(struct net_device *netdev)
3125 u32 mc_addr_count)
3126{ 3163{
3127 hw->mac.ops.update_mc_addr_list(hw, mc_addr_list, mc_addr_count); 3164 struct e1000_adapter *adapter = netdev_priv(netdev);
3165 struct e1000_hw *hw = &adapter->hw;
3166 unsigned int rar_entries = hw->mac.rar_entry_count;
3167 int count = 0;
3168
3169 /* save a rar entry for our hardware address */
3170 rar_entries--;
3171
3172 /* save a rar entry for the LAA workaround */
3173 if (adapter->flags & FLAG_RESET_OVERWRITES_LAA)
3174 rar_entries--;
3175
3176 /* return ENOMEM indicating insufficient memory for addresses */
3177 if (netdev_uc_count(netdev) > rar_entries)
3178 return -ENOMEM;
3179
3180 if (!netdev_uc_empty(netdev) && rar_entries) {
3181 struct netdev_hw_addr *ha;
3182
3183 /*
3184 * write the addresses in reverse order to avoid write
3185 * combining
3186 */
3187 netdev_for_each_uc_addr(ha, netdev) {
3188 if (!rar_entries)
3189 break;
3190 e1000e_rar_set(hw, ha->addr, rar_entries--);
3191 count++;
3192 }
3193 }
3194
3195 /* zero out the remaining RAR entries not used above */
3196 for (; rar_entries > 0; rar_entries--) {
3197 ew32(RAH(rar_entries), 0);
3198 ew32(RAL(rar_entries), 0);
3199 }
3200 e1e_flush();
3201
3202 return count;
3128} 3203}
3129 3204
3130/** 3205/**
3131 * e1000_set_multi - Multicast and Promiscuous mode set 3206 * e1000e_set_rx_mode - secondary unicast, Multicast and Promiscuous mode set
3132 * @netdev: network interface device structure 3207 * @netdev: network interface device structure
3133 * 3208 *
3134 * The set_multi entry point is called whenever the multicast address 3209 * The ndo_set_rx_mode entry point is called whenever the unicast or multicast
3135 * list or the network interface flags are updated. This routine is 3210 * address list or the network interface flags are updated. This routine is
3136 * responsible for configuring the hardware for proper multicast, 3211 * responsible for configuring the hardware for proper unicast, multicast,
3137 * promiscuous mode, and all-multi behavior. 3212 * promiscuous mode, and all-multi behavior.
3138 **/ 3213 **/
3139static void e1000_set_multi(struct net_device *netdev) 3214static void e1000e_set_rx_mode(struct net_device *netdev)
3140{ 3215{
3141 struct e1000_adapter *adapter = netdev_priv(netdev); 3216 struct e1000_adapter *adapter = netdev_priv(netdev);
3142 struct e1000_hw *hw = &adapter->hw; 3217 struct e1000_hw *hw = &adapter->hw;
3143 struct netdev_hw_addr *ha;
3144 u8 *mta_list;
3145 u32 rctl; 3218 u32 rctl;
3146 3219
3147 /* Check for Promiscuous and All Multicast modes */ 3220 /* Check for Promiscuous and All Multicast modes */
3148
3149 rctl = er32(RCTL); 3221 rctl = er32(RCTL);
3150 3222
3223 /* clear the affected bits */
3224 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
3225
3151 if (netdev->flags & IFF_PROMISC) { 3226 if (netdev->flags & IFF_PROMISC) {
3152 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); 3227 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
3153 rctl &= ~E1000_RCTL_VFE;
3154 /* Do not hardware filter VLANs in promisc mode */ 3228 /* Do not hardware filter VLANs in promisc mode */
3155 e1000e_vlan_filter_disable(adapter); 3229 e1000e_vlan_filter_disable(adapter);
3156 } else { 3230 } else {
3231 int count;
3157 if (netdev->flags & IFF_ALLMULTI) { 3232 if (netdev->flags & IFF_ALLMULTI) {
3158 rctl |= E1000_RCTL_MPE; 3233 rctl |= E1000_RCTL_MPE;
3159 rctl &= ~E1000_RCTL_UPE;
3160 } else { 3234 } else {
3161 rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE); 3235 /*
3236 * Write addresses to the MTA, if the attempt fails
3237 * then we should just turn on promiscuous mode so
3238 * that we can at least receive multicast traffic
3239 */
3240 count = e1000e_write_mc_addr_list(netdev);
3241 if (count < 0)
3242 rctl |= E1000_RCTL_MPE;
3162 } 3243 }
3163 e1000e_vlan_filter_enable(adapter); 3244 e1000e_vlan_filter_enable(adapter);
3164 }
3165
3166 ew32(RCTL, rctl);
3167
3168 if (!netdev_mc_empty(netdev)) {
3169 int i = 0;
3170
3171 mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
3172 if (!mta_list)
3173 return;
3174
3175 /* prepare a packed array of only addresses. */
3176 netdev_for_each_mc_addr(ha, netdev)
3177 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN);
3178
3179 e1000_update_mc_addr_list(hw, mta_list, i);
3180 kfree(mta_list);
3181 } else {
3182 /* 3245 /*
3183 * if we're called from probe, we might not have 3246 * Write addresses to available RAR registers, if there is not
3184 * anything to do here, so clear out the list 3247 * sufficient space to store all the addresses then enable
3248 * unicast promiscuous mode
3185 */ 3249 */
3186 e1000_update_mc_addr_list(hw, NULL, 0); 3250 count = e1000e_write_uc_addr_list(netdev);
3251 if (count < 0)
3252 rctl |= E1000_RCTL_UPE;
3187 } 3253 }
3188 3254
3255 ew32(RCTL, rctl);
3256
3189 if (netdev->features & NETIF_F_HW_VLAN_RX) 3257 if (netdev->features & NETIF_F_HW_VLAN_RX)
3190 e1000e_vlan_strip_enable(adapter); 3258 e1000e_vlan_strip_enable(adapter);
3191 else 3259 else
@@ -3198,7 +3266,7 @@ static void e1000_set_multi(struct net_device *netdev)
3198 **/ 3266 **/
3199static void e1000_configure(struct e1000_adapter *adapter) 3267static void e1000_configure(struct e1000_adapter *adapter)
3200{ 3268{
3201 e1000_set_multi(adapter->netdev); 3269 e1000e_set_rx_mode(adapter->netdev);
3202 3270
3203 e1000_restore_vlan(adapter); 3271 e1000_restore_vlan(adapter);
3204 e1000_init_manageability_pt(adapter); 3272 e1000_init_manageability_pt(adapter);
@@ -5331,7 +5399,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
5331 5399
5332 if (wufc) { 5400 if (wufc) {
5333 e1000_setup_rctl(adapter); 5401 e1000_setup_rctl(adapter);
5334 e1000_set_multi(netdev); 5402 e1000e_set_rx_mode(netdev);
5335 5403
5336 /* turn on all-multi mode if wake on multicast is enabled */ 5404 /* turn on all-multi mode if wake on multicast is enabled */
5337 if (wufc & E1000_WUFC_MC) { 5405 if (wufc & E1000_WUFC_MC) {
@@ -5884,7 +5952,7 @@ static const struct net_device_ops e1000e_netdev_ops = {
5884 .ndo_stop = e1000_close, 5952 .ndo_stop = e1000_close,
5885 .ndo_start_xmit = e1000_xmit_frame, 5953 .ndo_start_xmit = e1000_xmit_frame,
5886 .ndo_get_stats64 = e1000e_get_stats64, 5954 .ndo_get_stats64 = e1000e_get_stats64,
5887 .ndo_set_rx_mode = e1000_set_multi, 5955 .ndo_set_rx_mode = e1000e_set_rx_mode,
5888 .ndo_set_mac_address = e1000_set_mac, 5956 .ndo_set_mac_address = e1000_set_mac,
5889 .ndo_change_mtu = e1000_change_mtu, 5957 .ndo_change_mtu = e1000_change_mtu,
5890 .ndo_do_ioctl = e1000_ioctl, 5958 .ndo_do_ioctl = e1000_ioctl,
@@ -6076,6 +6144,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
6076 NETIF_F_TSO6 | 6144 NETIF_F_TSO6 |
6077 NETIF_F_HW_CSUM); 6145 NETIF_F_HW_CSUM);
6078 6146
6147 netdev->priv_flags |= IFF_UNICAST_FLT;
6148
6079 if (pci_using_dac) { 6149 if (pci_using_dac) {
6080 netdev->features |= NETIF_F_HIGHDMA; 6150 netdev->features |= NETIF_F_HIGHDMA;
6081 netdev->vlan_features |= NETIF_F_HIGHDMA; 6151 netdev->vlan_features |= NETIF_F_HIGHDMA;