Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ixgbe: add support for Dell CEM

This patch adds support for Dell CEM (Comprehensive Embedded Management)).
This consists of informing the management firmware of the driver version
during probe on 82599 and X540 HW.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Evan Swanson <evan.swanson@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

authored by

Emil Tantilov and committed by
Jeff Kirsher
9612de92 fb5475ff

+229
+1
drivers/net/ixgbe/ixgbe_82598.c
··· 1316 1316 .clear_vfta = &ixgbe_clear_vfta_82598, 1317 1317 .set_vfta = &ixgbe_set_vfta_82598, 1318 1318 .fc_enable = &ixgbe_fc_enable_82598, 1319 + .set_fw_drv_ver = NULL, 1319 1320 .acquire_swfw_sync = &ixgbe_acquire_swfw_sync, 1320 1321 .release_swfw_sync = &ixgbe_release_swfw_sync, 1321 1322 };
+1
drivers/net/ixgbe/ixgbe_82599.c
··· 2126 2126 .clear_vfta = &ixgbe_clear_vfta_generic, 2127 2127 .set_vfta = &ixgbe_set_vfta_generic, 2128 2128 .fc_enable = &ixgbe_fc_enable_generic, 2129 + .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic, 2129 2130 .init_uta_tables = &ixgbe_init_uta_tables_generic, 2130 2131 .setup_sfp = &ixgbe_setup_sfp_modules_82599, 2131 2132 .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing,
+174
drivers/net/ixgbe/ixgbe_common.c
··· 3333 3333 IXGBE_WRITE_REG(hw, IXGBE_TXPBTHRESH(i), 0); 3334 3334 } 3335 3335 } 3336 + 3337 + /** 3338 + * ixgbe_calculate_checksum - Calculate checksum for buffer 3339 + * @buffer: pointer to EEPROM 3340 + * @length: size of EEPROM to calculate a checksum for 3341 + * Calculates the checksum for some buffer on a specified length. The 3342 + * checksum calculated is returned. 3343 + **/ 3344 + static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length) 3345 + { 3346 + u32 i; 3347 + u8 sum = 0; 3348 + 3349 + if (!buffer) 3350 + return 0; 3351 + 3352 + for (i = 0; i < length; i++) 3353 + sum += buffer[i]; 3354 + 3355 + return (u8) (0 - sum); 3356 + } 3357 + 3358 + /** 3359 + * ixgbe_host_interface_command - Issue command to manageability block 3360 + * @hw: pointer to the HW structure 3361 + * @buffer: contains the command to write and where the return status will 3362 + * be placed 3363 + * @lenght: lenght of buffer, must be multiple of 4 bytes 3364 + * 3365 + * Communicates with the manageability block. On success return 0 3366 + * else return IXGBE_ERR_HOST_INTERFACE_COMMAND. 3367 + **/ 3368 + static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u8 *buffer, 3369 + u32 length) 3370 + { 3371 + u32 hicr, i; 3372 + u32 hdr_size = sizeof(struct ixgbe_hic_hdr); 3373 + u8 buf_len, dword_len; 3374 + 3375 + s32 ret_val = 0; 3376 + 3377 + if (length == 0 || length & 0x3 || 3378 + length > IXGBE_HI_MAX_BLOCK_BYTE_LENGTH) { 3379 + hw_dbg(hw, "Buffer length failure.\n"); 3380 + ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; 3381 + goto out; 3382 + } 3383 + 3384 + /* Check that the host interface is enabled. */ 3385 + hicr = IXGBE_READ_REG(hw, IXGBE_HICR); 3386 + if ((hicr & IXGBE_HICR_EN) == 0) { 3387 + hw_dbg(hw, "IXGBE_HOST_EN bit disabled.\n"); 3388 + ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; 3389 + goto out; 3390 + } 3391 + 3392 + /* Calculate length in DWORDs */ 3393 + dword_len = length >> 2; 3394 + 3395 + /* 3396 + * The device driver writes the relevant command block 3397 + * into the ram area. 3398 + */ 3399 + for (i = 0; i < dword_len; i++) 3400 + IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG, 3401 + i, *((u32 *)buffer + i)); 3402 + 3403 + /* Setting this bit tells the ARC that a new command is pending. */ 3404 + IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C); 3405 + 3406 + for (i = 0; i < IXGBE_HI_COMMAND_TIMEOUT; i++) { 3407 + hicr = IXGBE_READ_REG(hw, IXGBE_HICR); 3408 + if (!(hicr & IXGBE_HICR_C)) 3409 + break; 3410 + usleep_range(1000, 2000); 3411 + } 3412 + 3413 + /* Check command successful completion. */ 3414 + if (i == IXGBE_HI_COMMAND_TIMEOUT || 3415 + (!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV))) { 3416 + hw_dbg(hw, "Command has failed with no status valid.\n"); 3417 + ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; 3418 + goto out; 3419 + } 3420 + 3421 + /* Calculate length in DWORDs */ 3422 + dword_len = hdr_size >> 2; 3423 + 3424 + /* first pull in the header so we know the buffer length */ 3425 + for (i = 0; i < dword_len; i++) 3426 + *((u32 *)buffer + i) = 3427 + IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); 3428 + 3429 + /* If there is any thing in data position pull it in */ 3430 + buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len; 3431 + if (buf_len == 0) 3432 + goto out; 3433 + 3434 + if (length < (buf_len + hdr_size)) { 3435 + hw_dbg(hw, "Buffer not large enough for reply message.\n"); 3436 + ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; 3437 + goto out; 3438 + } 3439 + 3440 + /* Calculate length in DWORDs, add one for odd lengths */ 3441 + dword_len = (buf_len + 1) >> 2; 3442 + 3443 + /* Pull in the rest of the buffer (i is where we left off)*/ 3444 + for (; i < buf_len; i++) 3445 + *((u32 *)buffer + i) = 3446 + IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i); 3447 + 3448 + out: 3449 + return ret_val; 3450 + } 3451 + 3452 + /** 3453 + * ixgbe_set_fw_drv_ver_generic - Sends driver version to firmware 3454 + * @hw: pointer to the HW structure 3455 + * @maj: driver version major number 3456 + * @min: driver version minor number 3457 + * @build: driver version build number 3458 + * @sub: driver version sub build number 3459 + * 3460 + * Sends driver version number to firmware through the manageability 3461 + * block. On success return 0 3462 + * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring 3463 + * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails. 3464 + **/ 3465 + s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, 3466 + u8 build, u8 sub) 3467 + { 3468 + struct ixgbe_hic_drv_info fw_cmd; 3469 + int i; 3470 + s32 ret_val = 0; 3471 + 3472 + if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM) != 0) { 3473 + ret_val = IXGBE_ERR_SWFW_SYNC; 3474 + goto out; 3475 + } 3476 + 3477 + fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO; 3478 + fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN; 3479 + fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED; 3480 + fw_cmd.port_num = (u8)hw->bus.func; 3481 + fw_cmd.ver_maj = maj; 3482 + fw_cmd.ver_min = min; 3483 + fw_cmd.ver_build = build; 3484 + fw_cmd.ver_sub = sub; 3485 + fw_cmd.hdr.checksum = 0; 3486 + fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd, 3487 + (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len)); 3488 + fw_cmd.pad = 0; 3489 + fw_cmd.pad2 = 0; 3490 + 3491 + for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) { 3492 + ret_val = ixgbe_host_interface_command(hw, (u8 *)&fw_cmd, 3493 + sizeof(fw_cmd)); 3494 + if (ret_val != 0) 3495 + continue; 3496 + 3497 + if (fw_cmd.hdr.cmd_or_resp.ret_status == 3498 + FW_CEM_RESP_STATUS_SUCCESS) 3499 + ret_val = 0; 3500 + else 3501 + ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND; 3502 + 3503 + break; 3504 + } 3505 + 3506 + hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM); 3507 + out: 3508 + return ret_val; 3509 + }
+2
drivers/net/ixgbe/ixgbe_common.h
··· 99 99 void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf); 100 100 void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf); 101 101 s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps); 102 + s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min, 103 + u8 build, u8 ver); 102 104 103 105 void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, 104 106 u32 headroom, int strategy);
+4
drivers/net/ixgbe/ixgbe_main.c
··· 7674 7674 ixgbe_vf_configuration(pdev, (i | 0x10000000)); 7675 7675 } 7676 7676 7677 + /* Inform firmware of driver version */ 7678 + if (hw->mac.ops.set_fw_drv_ver) 7679 + hw->mac.ops.set_fw_drv_ver(hw, MAJ, MIN, BUILD, KFIX); 7680 + 7677 7681 /* add san mac addr to netdev */ 7678 7682 ixgbe_add_sanmac_netdev(netdev); 7679 7683
+46
drivers/net/ixgbe/ixgbe_type.h
··· 707 707 #define IXGBE_HFDR 0x15FE8 708 708 #define IXGBE_FLEX_MNG 0x15800 /* 0x15800 - 0x15EFC */ 709 709 710 + #define IXGBE_HICR_EN 0x01 /* Enable bit - RO */ 711 + /* Driver sets this bit when done to put command in RAM */ 712 + #define IXGBE_HICR_C 0x02 713 + #define IXGBE_HICR_SV 0x04 /* Status Validity */ 714 + #define IXGBE_HICR_FW_RESET_ENABLE 0x40 715 + #define IXGBE_HICR_FW_RESET 0x80 716 + 710 717 /* PCI-E registers */ 711 718 #define IXGBE_GCR 0x11000 712 719 #define IXGBE_GTV 0x11004 ··· 2131 2124 #define IXGBE_FDIR_INIT_DONE_POLL 10 2132 2125 #define IXGBE_FDIRCMD_CMD_POLL 10 2133 2126 2127 + /* Manageablility Host Interface defines */ 2128 + #define IXGBE_HI_MAX_BLOCK_BYTE_LENGTH 1792 /* Num of bytes in range */ 2129 + #define IXGBE_HI_MAX_BLOCK_DWORD_LENGTH 448 /* Num of dwords in range */ 2130 + #define IXGBE_HI_COMMAND_TIMEOUT 500 /* Process HI command limit */ 2131 + 2132 + /* CEM Support */ 2133 + #define FW_CEM_HDR_LEN 0x4 2134 + #define FW_CEM_CMD_DRIVER_INFO 0xDD 2135 + #define FW_CEM_CMD_DRIVER_INFO_LEN 0x5 2136 + #define FW_CEM_CMD_RESERVED 0X0 2137 + #define FW_CEM_MAX_RETRIES 3 2138 + #define FW_CEM_RESP_STATUS_SUCCESS 0x1 2139 + 2140 + /* Host Interface Command Structures */ 2141 + struct ixgbe_hic_hdr { 2142 + u8 cmd; 2143 + u8 buf_len; 2144 + union { 2145 + u8 cmd_resv; 2146 + u8 ret_status; 2147 + } cmd_or_resp; 2148 + u8 checksum; 2149 + }; 2150 + 2151 + struct ixgbe_hic_drv_info { 2152 + struct ixgbe_hic_hdr hdr; 2153 + u8 port_num; 2154 + u8 ver_sub; 2155 + u8 ver_build; 2156 + u8 ver_min; 2157 + u8 ver_maj; 2158 + u8 pad; /* end spacing to ensure length is mult. of dword */ 2159 + u16 pad2; /* end spacing to ensure length is mult. of dword2 */ 2160 + }; 2161 + 2134 2162 /* Transmit Descriptor - Advanced */ 2135 2163 union ixgbe_adv_tx_desc { 2136 2164 struct { ··· 2705 2663 2706 2664 /* Flow Control */ 2707 2665 s32 (*fc_enable)(struct ixgbe_hw *, s32); 2666 + 2667 + /* Manageability interface */ 2668 + s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8); 2708 2669 }; 2709 2670 2710 2671 struct ixgbe_phy_operations { ··· 2877 2832 #define IXGBE_ERR_SFP_SETUP_NOT_COMPLETE -30 2878 2833 #define IXGBE_ERR_PBA_SECTION -31 2879 2834 #define IXGBE_ERR_INVALID_ARGUMENT -32 2835 + #define IXGBE_ERR_HOST_INTERFACE_COMMAND -33 2880 2836 #define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF 2881 2837 2882 2838 #endif /* _IXGBE_TYPE_H_ */
+1
drivers/net/ixgbe/ixgbe_x540.c
··· 894 894 .clear_vfta = &ixgbe_clear_vfta_generic, 895 895 .set_vfta = &ixgbe_set_vfta_generic, 896 896 .fc_enable = &ixgbe_fc_enable_generic, 897 + .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic, 897 898 .init_uta_tables = &ixgbe_init_uta_tables_generic, 898 899 .setup_sfp = NULL, 899 900 .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing,