diff options
| author | Ben Hutchings <bhutchings@solarflare.com> | 2012-09-14 12:30:10 -0400 |
|---|---|---|
| committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-08-21 11:35:21 -0400 |
| commit | 59cfc479b2c8ba344c8497d5c913b6cba2ce3755 (patch) | |
| tree | 77ed4c951751fee608d73ef9d0c081199ba77372 | |
| parent | ab0115fc7dc429300fc6b728ab04ee832fbb945d (diff) | |
sfc: Introduce and use MCDI_DECLARE_BUF macro
MCDI_DECLARE_BUF declares a variable as an MCDI buffer of the
requested length, adding any necessary padding.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
| -rw-r--r-- | drivers/net/ethernet/sfc/mcdi.c | 52 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/mcdi.h | 3 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/mcdi_mac.c | 17 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/mcdi_mon.c | 4 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/mcdi_phy.c | 26 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/ptp.c | 16 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/siena_sriov.c | 4 |
7 files changed, 66 insertions, 56 deletions
diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c index 97dd8f18c001..d65b562af567 100644 --- a/drivers/net/ethernet/sfc/mcdi.c +++ b/drivers/net/ethernet/sfc/mcdi.c | |||
| @@ -606,7 +606,7 @@ void efx_mcdi_process_event(struct efx_channel *channel, | |||
| 606 | 606 | ||
| 607 | void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len) | 607 | void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len) |
| 608 | { | 608 | { |
| 609 | u8 outbuf[ALIGN(MC_CMD_GET_VERSION_OUT_LEN, 4)]; | 609 | MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_VERSION_OUT_LEN); |
| 610 | size_t outlength; | 610 | size_t outlength; |
| 611 | const __le16 *ver_words; | 611 | const __le16 *ver_words; |
| 612 | int rc; | 612 | int rc; |
| @@ -637,8 +637,8 @@ fail: | |||
| 637 | int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, | 637 | int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, |
| 638 | bool *was_attached) | 638 | bool *was_attached) |
| 639 | { | 639 | { |
| 640 | u8 inbuf[MC_CMD_DRV_ATTACH_IN_LEN]; | 640 | MCDI_DECLARE_BUF(inbuf, MC_CMD_DRV_ATTACH_IN_LEN); |
| 641 | u8 outbuf[MC_CMD_DRV_ATTACH_OUT_LEN]; | 641 | MCDI_DECLARE_BUF(outbuf, MC_CMD_DRV_ATTACH_OUT_LEN); |
| 642 | size_t outlen; | 642 | size_t outlen; |
| 643 | int rc; | 643 | int rc; |
| 644 | 644 | ||
| @@ -667,7 +667,7 @@ fail: | |||
| 667 | int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, | 667 | int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, |
| 668 | u16 *fw_subtype_list, u32 *capabilities) | 668 | u16 *fw_subtype_list, u32 *capabilities) |
| 669 | { | 669 | { |
| 670 | uint8_t outbuf[MC_CMD_GET_BOARD_CFG_OUT_LENMAX]; | 670 | MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_BOARD_CFG_OUT_LENMAX); |
| 671 | size_t outlen, offset, i; | 671 | size_t outlen, offset, i; |
| 672 | int port_num = efx_port_num(efx); | 672 | int port_num = efx_port_num(efx); |
| 673 | int rc; | 673 | int rc; |
| @@ -721,7 +721,7 @@ fail: | |||
| 721 | 721 | ||
| 722 | int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq) | 722 | int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq) |
| 723 | { | 723 | { |
| 724 | u8 inbuf[MC_CMD_LOG_CTRL_IN_LEN]; | 724 | MCDI_DECLARE_BUF(inbuf, MC_CMD_LOG_CTRL_IN_LEN); |
| 725 | u32 dest = 0; | 725 | u32 dest = 0; |
| 726 | int rc; | 726 | int rc; |
| 727 | 727 | ||
| @@ -749,7 +749,7 @@ fail: | |||
| 749 | 749 | ||
| 750 | int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out) | 750 | int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out) |
| 751 | { | 751 | { |
| 752 | u8 outbuf[MC_CMD_NVRAM_TYPES_OUT_LEN]; | 752 | MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_TYPES_OUT_LEN); |
| 753 | size_t outlen; | 753 | size_t outlen; |
| 754 | int rc; | 754 | int rc; |
| 755 | 755 | ||
| @@ -777,8 +777,8 @@ int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type, | |||
| 777 | size_t *size_out, size_t *erase_size_out, | 777 | size_t *size_out, size_t *erase_size_out, |
| 778 | bool *protected_out) | 778 | bool *protected_out) |
| 779 | { | 779 | { |
| 780 | u8 inbuf[MC_CMD_NVRAM_INFO_IN_LEN]; | 780 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_INFO_IN_LEN); |
| 781 | u8 outbuf[MC_CMD_NVRAM_INFO_OUT_LEN]; | 781 | MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_INFO_OUT_LEN); |
| 782 | size_t outlen; | 782 | size_t outlen; |
| 783 | int rc; | 783 | int rc; |
| 784 | 784 | ||
| @@ -806,7 +806,7 @@ fail: | |||
| 806 | 806 | ||
| 807 | int efx_mcdi_nvram_update_start(struct efx_nic *efx, unsigned int type) | 807 | int efx_mcdi_nvram_update_start(struct efx_nic *efx, unsigned int type) |
| 808 | { | 808 | { |
| 809 | u8 inbuf[MC_CMD_NVRAM_UPDATE_START_IN_LEN]; | 809 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_UPDATE_START_IN_LEN); |
| 810 | int rc; | 810 | int rc; |
| 811 | 811 | ||
| 812 | MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_START_IN_TYPE, type); | 812 | MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_START_IN_TYPE, type); |
| @@ -828,8 +828,9 @@ fail: | |||
| 828 | int efx_mcdi_nvram_read(struct efx_nic *efx, unsigned int type, | 828 | int efx_mcdi_nvram_read(struct efx_nic *efx, unsigned int type, |
| 829 | loff_t offset, u8 *buffer, size_t length) | 829 | loff_t offset, u8 *buffer, size_t length) |
| 830 | { | 830 | { |
| 831 | u8 inbuf[MC_CMD_NVRAM_READ_IN_LEN]; | 831 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_READ_IN_LEN); |
| 832 | u8 outbuf[MC_CMD_NVRAM_READ_OUT_LEN(EFX_MCDI_NVRAM_LEN_MAX)]; | 832 | MCDI_DECLARE_BUF(outbuf, |
| 833 | MC_CMD_NVRAM_READ_OUT_LEN(EFX_MCDI_NVRAM_LEN_MAX)); | ||
| 833 | size_t outlen; | 834 | size_t outlen; |
| 834 | int rc; | 835 | int rc; |
| 835 | 836 | ||
| @@ -853,7 +854,8 @@ fail: | |||
| 853 | int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type, | 854 | int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type, |
| 854 | loff_t offset, const u8 *buffer, size_t length) | 855 | loff_t offset, const u8 *buffer, size_t length) |
| 855 | { | 856 | { |
| 856 | u8 inbuf[MC_CMD_NVRAM_WRITE_IN_LEN(EFX_MCDI_NVRAM_LEN_MAX)]; | 857 | MCDI_DECLARE_BUF(inbuf, |
| 858 | MC_CMD_NVRAM_WRITE_IN_LEN(EFX_MCDI_NVRAM_LEN_MAX)); | ||
| 857 | int rc; | 859 | int rc; |
| 858 | 860 | ||
| 859 | MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_TYPE, type); | 861 | MCDI_SET_DWORD(inbuf, NVRAM_WRITE_IN_TYPE, type); |
| @@ -879,7 +881,7 @@ fail: | |||
| 879 | int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type, | 881 | int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type, |
| 880 | loff_t offset, size_t length) | 882 | loff_t offset, size_t length) |
| 881 | { | 883 | { |
| 882 | u8 inbuf[MC_CMD_NVRAM_ERASE_IN_LEN]; | 884 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_ERASE_IN_LEN); |
| 883 | int rc; | 885 | int rc; |
| 884 | 886 | ||
| 885 | MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_TYPE, type); | 887 | MCDI_SET_DWORD(inbuf, NVRAM_ERASE_IN_TYPE, type); |
| @@ -902,7 +904,7 @@ fail: | |||
| 902 | 904 | ||
| 903 | int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type) | 905 | int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type) |
| 904 | { | 906 | { |
| 905 | u8 inbuf[MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN]; | 907 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_UPDATE_FINISH_IN_LEN); |
| 906 | int rc; | 908 | int rc; |
| 907 | 909 | ||
| 908 | MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_FINISH_IN_TYPE, type); | 910 | MCDI_SET_DWORD(inbuf, NVRAM_UPDATE_FINISH_IN_TYPE, type); |
| @@ -923,8 +925,8 @@ fail: | |||
| 923 | 925 | ||
| 924 | static int efx_mcdi_nvram_test(struct efx_nic *efx, unsigned int type) | 926 | static int efx_mcdi_nvram_test(struct efx_nic *efx, unsigned int type) |
| 925 | { | 927 | { |
| 926 | u8 inbuf[MC_CMD_NVRAM_TEST_IN_LEN]; | 928 | MCDI_DECLARE_BUF(inbuf, MC_CMD_NVRAM_TEST_IN_LEN); |
| 927 | u8 outbuf[MC_CMD_NVRAM_TEST_OUT_LEN]; | 929 | MCDI_DECLARE_BUF(outbuf, MC_CMD_NVRAM_TEST_OUT_LEN); |
| 928 | int rc; | 930 | int rc; |
| 929 | 931 | ||
| 930 | MCDI_SET_DWORD(inbuf, NVRAM_TEST_IN_TYPE, type); | 932 | MCDI_SET_DWORD(inbuf, NVRAM_TEST_IN_TYPE, type); |
| @@ -976,8 +978,8 @@ fail1: | |||
| 976 | 978 | ||
| 977 | static int efx_mcdi_read_assertion(struct efx_nic *efx) | 979 | static int efx_mcdi_read_assertion(struct efx_nic *efx) |
| 978 | { | 980 | { |
| 979 | u8 inbuf[MC_CMD_GET_ASSERTS_IN_LEN]; | 981 | MCDI_DECLARE_BUF(inbuf, MC_CMD_GET_ASSERTS_IN_LEN); |
| 980 | u8 outbuf[MC_CMD_GET_ASSERTS_OUT_LEN]; | 982 | MCDI_DECLARE_BUF(outbuf, MC_CMD_GET_ASSERTS_OUT_LEN); |
| 981 | unsigned int flags, index, ofst; | 983 | unsigned int flags, index, ofst; |
| 982 | const char *reason; | 984 | const char *reason; |
| 983 | size_t outlen; | 985 | size_t outlen; |
| @@ -1032,7 +1034,7 @@ static int efx_mcdi_read_assertion(struct efx_nic *efx) | |||
| 1032 | 1034 | ||
| 1033 | static void efx_mcdi_exit_assertion(struct efx_nic *efx) | 1035 | static void efx_mcdi_exit_assertion(struct efx_nic *efx) |
| 1034 | { | 1036 | { |
| 1035 | u8 inbuf[MC_CMD_REBOOT_IN_LEN]; | 1037 | MCDI_DECLARE_BUF(inbuf, MC_CMD_REBOOT_IN_LEN); |
| 1036 | 1038 | ||
| 1037 | /* If the MC is running debug firmware, it might now be | 1039 | /* If the MC is running debug firmware, it might now be |
| 1038 | * waiting for a debugger to attach, but we just want it to | 1040 | * waiting for a debugger to attach, but we just want it to |
| @@ -1062,7 +1064,7 @@ int efx_mcdi_handle_assertion(struct efx_nic *efx) | |||
| 1062 | 1064 | ||
| 1063 | void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) | 1065 | void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode) |
| 1064 | { | 1066 | { |
