Deleted Added
full compact
e1000_vf.c (225736) e1000_vf.c (235527)
1/******************************************************************************
2
1/******************************************************************************
2
3 Copyright (c) 2001-2010, Intel Corporation
3 Copyright (c) 2001-2011, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11

--- 13 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32******************************************************************************/
33/*$FreeBSD: stable/9/sys/dev/e1000/e1000_vf.c 218530 2011-02-11 01:00:26Z jfv $*/
33/*$FreeBSD: stable/9/sys/dev/e1000/e1000_vf.c 235527 2012-05-16 22:22:52Z jfv $*/
34
35
36#include "e1000_api.h"
37
38
34
35
36#include "e1000_api.h"
37
38
39static s32 e1000_init_phy_params_vf(struct e1000_hw *hw);
40static s32 e1000_init_nvm_params_vf(struct e1000_hw *hw);
41static void e1000_release_vf(struct e1000_hw *hw);
42static s32 e1000_acquire_vf(struct e1000_hw *hw);
43static s32 e1000_setup_link_vf(struct e1000_hw *hw);
44static s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
45static s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
46static s32 e1000_check_for_link_vf(struct e1000_hw *hw);
47static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
48 u16 *duplex);
49static s32 e1000_init_hw_vf(struct e1000_hw *hw);
50static s32 e1000_reset_hw_vf(struct e1000_hw *hw);
51static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
52static void e1000_rar_set_vf(struct e1000_hw *, u8 *, u32);
53static s32 e1000_read_mac_addr_vf(struct e1000_hw *);
39static s32 e1000_init_phy_params_vf(struct e1000_hw *hw);
40static s32 e1000_init_nvm_params_vf(struct e1000_hw *hw);
41static void e1000_release_vf(struct e1000_hw *hw);
42static s32 e1000_acquire_vf(struct e1000_hw *hw);
43static s32 e1000_setup_link_vf(struct e1000_hw *hw);
44static s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
45static s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
46static s32 e1000_check_for_link_vf(struct e1000_hw *hw);
47static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
48 u16 *duplex);
49static s32 e1000_init_hw_vf(struct e1000_hw *hw);
50static s32 e1000_reset_hw_vf(struct e1000_hw *hw);
51static void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
52static void e1000_rar_set_vf(struct e1000_hw *, u8 *, u32);
53static s32 e1000_read_mac_addr_vf(struct e1000_hw *);
54
55/**
56 * e1000_init_phy_params_vf - Inits PHY params
57 * @hw: pointer to the HW structure
58 *
59 * Doesn't do much - there's no PHY available to the VF.
60 **/
61static s32 e1000_init_phy_params_vf(struct e1000_hw *hw)

--- 152 unchanged lines hidden (view full) ---

214 * @hw: pointer to the HW structure
215 * @speed: pointer to 16 bit value to store link speed.
216 * @duplex: pointer to 16 bit value to store duplex.
217 *
218 * Since we cannot read the PHY and get accurate link info, we must rely upon
219 * the status register's data which is often stale and inaccurate.
220 **/
221static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
54
55/**
56 * e1000_init_phy_params_vf - Inits PHY params
57 * @hw: pointer to the HW structure
58 *
59 * Doesn't do much - there's no PHY available to the VF.
60 **/
61static s32 e1000_init_phy_params_vf(struct e1000_hw *hw)

--- 152 unchanged lines hidden (view full) ---

214 * @hw: pointer to the HW structure
215 * @speed: pointer to 16 bit value to store link speed.
216 * @duplex: pointer to 16 bit value to store duplex.
217 *
218 * Since we cannot read the PHY and get accurate link info, we must rely upon
219 * the status register's data which is often stale and inaccurate.
220 **/
221static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
222 u16 *duplex)
222 u16 *duplex)
223{
224 s32 status;
225
226 DEBUGFUNC("e1000_get_link_up_info_vf");
227
228 status = E1000_READ_REG(hw, E1000_STATUS);
229 if (status & E1000_STATUS_SPEED_1000) {
230 *speed = SPEED_1000;

--- 52 unchanged lines hidden (view full) ---

283 mbx->ops.write_posted(hw, msgbuf, 1, 0);
284
285 msec_delay(10);
286
287 /* set our "perm_addr" based on info provided by PF */
288 ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
289 if (!ret_val) {
290 if (msgbuf[0] == (E1000_VF_RESET |
223{
224 s32 status;
225
226 DEBUGFUNC("e1000_get_link_up_info_vf");
227
228 status = E1000_READ_REG(hw, E1000_STATUS);
229 if (status & E1000_STATUS_SPEED_1000) {
230 *speed = SPEED_1000;

--- 52 unchanged lines hidden (view full) ---

283 mbx->ops.write_posted(hw, msgbuf, 1, 0);
284
285 msec_delay(10);
286
287 /* set our "perm_addr" based on info provided by PF */
288 ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
289 if (!ret_val) {
290 if (msgbuf[0] == (E1000_VF_RESET |
291 E1000_VT_MSGTYPE_ACK))
291 E1000_VT_MSGTYPE_ACK))
292 memcpy(hw->mac.perm_addr, addr, 6);
293 else
294 ret_val = -E1000_ERR_MAC_INIT;
295 }
296 }
297
298 return ret_val;
299}

--- 64 unchanged lines hidden (view full) ---

364 /*
365 * The bit_shift is the number of left-shifts
366 * where 0xFF would still fall within the hash mask.
367 */
368 while (hash_mask >> bit_shift != 0xFF)
369 bit_shift++;
370
371 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
292 memcpy(hw->mac.perm_addr, addr, 6);
293 else
294 ret_val = -E1000_ERR_MAC_INIT;
295 }
296 }
297
298 return ret_val;
299}

--- 64 unchanged lines hidden (view full) ---

364 /*
365 * The bit_shift is the number of left-shifts
366 * where 0xFF would still fall within the hash mask.
367 */
368 while (hash_mask >> bit_shift != 0xFF)
369 bit_shift++;
370
371 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
372 (((u16) mc_addr[5]) << bit_shift)));
372 (((u16) mc_addr[5]) << bit_shift)));
373
374 return hash_value;
375}
376
373
374 return hash_value;
375}
376
377static void e1000_write_msg_read_ack(struct e1000_hw *hw,
378 u32 *msg, u16 size)
379{
380 struct e1000_mbx_info *mbx = &hw->mbx;
381 u32 retmsg[E1000_VFMAILBOX_SIZE];
382 s32 retval = mbx->ops.write_posted(hw, msg, size, 0);
383
384 if (!retval)
385 mbx->ops.read_posted(hw, retmsg, E1000_VFMAILBOX_SIZE, 0);
386}
387
377/**
378 * e1000_update_mc_addr_list_vf - Update Multicast addresses
379 * @hw: pointer to the HW structure
380 * @mc_addr_list: array of multicast addresses to program
381 * @mc_addr_count: number of multicast addresses to program
382 *
383 * Updates the Multicast Table Array.
384 * The caller must have a packed mc_addr_list of multicast addresses.
385 **/
386void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
388/**
389 * e1000_update_mc_addr_list_vf - Update Multicast addresses
390 * @hw: pointer to the HW structure
391 * @mc_addr_list: array of multicast addresses to program
392 * @mc_addr_count: number of multicast addresses to program
393 *
394 * Updates the Multicast Table Array.
395 * The caller must have a packed mc_addr_list of multicast addresses.
396 **/
397void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
387 u8 *mc_addr_list, u32 mc_addr_count)
398 u8 *mc_addr_list, u32 mc_addr_count)
388{
399{
389 struct e1000_mbx_info *mbx = &hw->mbx;
390 u32 msgbuf[E1000_VFMAILBOX_SIZE];
391 u16 *hash_list = (u16 *)&msgbuf[1];
392 u32 hash_value;
393 u32 i;
394
395 DEBUGFUNC("e1000_update_mc_addr_list_vf");
396
397 /* Each entry in the list uses 1 16 bit word. We have 30

--- 17 unchanged lines hidden (view full) ---

415
416 for (i = 0; i < mc_addr_count; i++) {
417 hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list);
418 DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
419 hash_list[i] = hash_value & 0x0FFF;
420 mc_addr_list += ETH_ADDR_LEN;
421 }
422
400 u32 msgbuf[E1000_VFMAILBOX_SIZE];
401 u16 *hash_list = (u16 *)&msgbuf[1];
402 u32 hash_value;
403 u32 i;
404
405 DEBUGFUNC("e1000_update_mc_addr_list_vf");
406
407 /* Each entry in the list uses 1 16 bit word. We have 30

--- 17 unchanged lines hidden (view full) ---

425
426 for (i = 0; i < mc_addr_count; i++) {
427 hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list);
428 DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
429 hash_list[i] = hash_value & 0x0FFF;
430 mc_addr_list += ETH_ADDR_LEN;
431 }
432
423 mbx->ops.write_posted(hw, msgbuf, E1000_VFMAILBOX_SIZE, 0);
433 e1000_write_msg_read_ack(hw, msgbuf, E1000_VFMAILBOX_SIZE);
424}
425
426/**
427 * e1000_vfta_set_vf - Set/Unset vlan filter table address
428 * @hw: pointer to the HW structure
429 * @vid: determines the vfta register and bit to set/unset
430 * @set: if TRUE then set bit, else clear bit
431 **/
432void e1000_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
433{
434}
435
436/**
437 * e1000_vfta_set_vf - Set/Unset vlan filter table address
438 * @hw: pointer to the HW structure
439 * @vid: determines the vfta register and bit to set/unset
440 * @set: if TRUE then set bit, else clear bit
441 **/
442void e1000_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
443{
434 struct e1000_mbx_info *mbx = &hw->mbx;
435 u32 msgbuf[2];
436
437 msgbuf[0] = E1000_VF_SET_VLAN;
438 msgbuf[1] = vid;
439 /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
440 if (set)
441 msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
442
444 u32 msgbuf[2];
445
446 msgbuf[0] = E1000_VF_SET_VLAN;
447 msgbuf[1] = vid;
448 /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
449 if (set)
450 msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
451
443 mbx->ops.write_posted(hw, msgbuf, 2, 0);
452 e1000_write_msg_read_ack(hw, msgbuf, 2);
444}
445
446/** e1000_rlpml_set_vf - Set the maximum receive packet length
447 * @hw: pointer to the HW structure
448 * @max_size: value to assign to max frame size
449 **/
450void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
451{
453}
454
455/** e1000_rlpml_set_vf - Set the maximum receive packet length
456 * @hw: pointer to the HW structure
457 * @max_size: value to assign to max frame size
458 **/
459void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
460{
452 struct e1000_mbx_info *mbx = &hw->mbx;
453 u32 msgbuf[2];
454
455 msgbuf[0] = E1000_VF_SET_LPE;
456 msgbuf[1] = max_size;
457
461 u32 msgbuf[2];
462
463 msgbuf[0] = E1000_VF_SET_LPE;
464 msgbuf[1] = max_size;
465
458 mbx->ops.write_posted(hw, msgbuf, 2, 0);
466 e1000_write_msg_read_ack(hw, msgbuf, 2);
459}
460
461/**
462 * e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
463 * @hw: pointer to the HW structure
464 * @uni: boolean indicating unicast promisc status
465 * @multi: boolean indicating multicast promisc status
466 **/

--- 108 unchanged lines hidden ---
467}
468
469/**
470 * e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
471 * @hw: pointer to the HW structure
472 * @uni: boolean indicating unicast promisc status
473 * @multi: boolean indicating multicast promisc status
474 **/

--- 108 unchanged lines hidden ---