Skip to content

Commit 5d6201e

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates 2014-12-09 This series contains updates to i40e and i40evf. Jeff (me) provides a single patch to convert a macro to a static inline function based on feedback from Joe Perches on a previous patch. Shannon provides the remaining twelve patches against i40e. Almost all of Shannon's patches cleanup/fix NVM issues varying in range from adding more detail to debug messages, to removing dead code, to fixing NVM state transitions after an error. Change the handy decoder interface for admin queue return code to help catch and properly report the condition as a useful errno rather than returning a misleading '0'. Added a range check to avoid any possible array index-out-of-bound issues. v2: - fixed up patch 05 in the series to use the ARRAY_SIZE() macro as suggested by Sergei Shtylyov - fix up patch 13 to remove unnecessary parens in the return statement as suggested by Sergei Shtylyov ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 602de7e + 4bd145b commit 5d6201e

File tree

8 files changed

+197
-111
lines changed

8 files changed

+197
-111
lines changed

drivers/net/ethernet/intel/i40e/i40e_adminq.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ i40e_status i40e_init_adminq(struct i40e_hw *hw)
617617

618618
/* pre-emptive resource lock release */
619619
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
620-
hw->aq.nvm_busy = false;
620+
hw->aq.nvm_release_on_done = false;
621+
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
621622

622623
ret_code = i40e_aq_set_hmc_resource_profile(hw,
623624
I40E_HMC_PROFILE_DEFAULT,
@@ -754,12 +755,6 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
754755
goto asq_send_command_exit;
755756
}
756757

757-
if (i40e_is_nvm_update_op(desc) && hw->aq.nvm_busy) {
758-
i40e_debug(hw, I40E_DEBUG_AQ_MESSAGE, "AQTX: NVM busy.\n");
759-
status = I40E_ERR_NVM;
760-
goto asq_send_command_exit;
761-
}
762-
763758
details = I40E_ADMINQ_DETAILS(hw->aq.asq, hw->aq.asq.next_to_use);
764759
if (cmd_details) {
765760
*details = *cmd_details;
@@ -901,9 +896,6 @@ i40e_status i40e_asq_send_command(struct i40e_hw *hw,
901896
status = I40E_ERR_ADMIN_QUEUE_TIMEOUT;
902897
}
903898

904-
if (!status && i40e_is_nvm_update_op(desc))
905-
hw->aq.nvm_busy = true;
906-
907899
asq_send_command_error:
908900
mutex_unlock(&hw->aq.asq_mutex);
909901
asq_send_command_exit:
@@ -1016,7 +1008,6 @@ i40e_status i40e_clean_arq_element(struct i40e_hw *hw,
10161008
mutex_unlock(&hw->aq.arq_mutex);
10171009

10181010
if (i40e_is_nvm_update_op(&e->desc)) {
1019-
hw->aq.nvm_busy = false;
10201011
if (hw->aq.nvm_release_on_done) {
10211012
i40e_release_nvm(hw);
10221013
hw->aq.nvm_release_on_done = false;

drivers/net/ethernet/intel/i40e/i40e_adminq.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define _I40E_ADMINQ_H_
2929

3030
#include "i40e_osdep.h"
31+
#include "i40e_status.h"
3132
#include "i40e_adminq_cmd.h"
3233

3334
#define I40E_ADMINQ_DESC(R, i) \
@@ -94,7 +95,6 @@ struct i40e_adminq_info {
9495
u16 fw_min_ver; /* firmware minor version */
9596
u16 api_maj_ver; /* api major version */
9697
u16 api_min_ver; /* api minor version */
97-
bool nvm_busy;
9898
bool nvm_release_on_done;
9999

100100
struct mutex asq_mutex; /* Send queue lock */
@@ -109,7 +109,7 @@ struct i40e_adminq_info {
109109
* i40e_aq_rc_to_posix - convert errors to user-land codes
110110
* aq_rc: AdminQ error code to convert
111111
**/
112-
static inline int i40e_aq_rc_to_posix(u16 aq_rc)
112+
static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
113113
{
114114
int aq_to_posix[] = {
115115
0, /* I40E_AQ_RC_OK */
@@ -137,6 +137,12 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
137137
-EFBIG, /* I40E_AQ_RC_EFBIG */
138138
};
139139

140+
/* aq_rc is invalid if AQ timed out */
141+
if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
142+
return -EAGAIN;
143+
144+
if (aq_rc >= ARRAY_SIZE(aq_to_posix))
145+
return -ERANGE;
140146
return aq_to_posix[aq_rc];
141147
}
142148

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static int i40e_get_eeprom(struct net_device *netdev,
822822
struct i40e_netdev_priv *np = netdev_priv(netdev);
823823
struct i40e_hw *hw = &np->vsi->back->hw;
824824
struct i40e_pf *pf = np->vsi->back;
825-
int ret_val = 0, len;
825+
int ret_val = 0, len, offset;
826826
u8 *eeprom_buff;
827827
u16 i, sectors;
828828
bool last;
@@ -835,19 +835,21 @@ static int i40e_get_eeprom(struct net_device *netdev,
835835
/* check for NVMUpdate access method */
836836
magic = hw->vendor_id | (hw->device_id << 16);
837837
if (eeprom->magic && eeprom->magic != magic) {
838+
struct i40e_nvm_access *cmd;
838839
int errno;
839840

840841
/* make sure it is the right magic for NVMUpdate */
841842
if ((eeprom->magic >> 16) != hw->device_id)
842843
return -EINVAL;
843844

844-
ret_val = i40e_nvmupd_command(hw,
845-
(struct i40e_nvm_access *)eeprom,
846-
bytes, &errno);
845+
cmd = (struct i40e_nvm_access *)eeprom;
846+
ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
847847
if (ret_val)
848848
dev_info(&pf->pdev->dev,
849-
"NVMUpdate read failed err=%d status=0x%x\n",
850-
ret_val, hw->aq.asq_last_status);
849+
"NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
850+
ret_val, hw->aq.asq_last_status, errno,
851+
(u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
852+
cmd->offset, cmd->data_size);
851853

852854
return errno;
853855
}
@@ -876,20 +878,29 @@ static int i40e_get_eeprom(struct net_device *netdev,
876878
len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i);
877879
last = true;
878880
}
879-
ret_val = i40e_aq_read_nvm(hw, 0x0,
880-
eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
881-
len,
881+
offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i),
882+
ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len,
882883
(u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i),
883884
last, NULL);
884-
if (ret_val) {
885+
if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) {
885886
dev_info(&pf->pdev->dev,
886-
"read NVM failed err=%d status=0x%x\n",
887-
ret_val, hw->aq.asq_last_status);
888-
goto release_nvm;
887+
"read NVM failed, invalid offset 0x%x\n",
888+
offset);
889+
break;
890+
} else if (ret_val &&
891+
hw->aq.asq_last_status == I40E_AQ_RC_EACCES) {
892+
dev_info(&pf->pdev->dev,
893+
"read NVM failed, access, offset 0x%x\n",
894+
offset);
895+
break;
896+
} else if (ret_val) {
897+
dev_info(&pf->pdev->dev,
898+
"read NVM failed offset %d err=%d status=0x%x\n",
899+
offset, ret_val, hw->aq.asq_last_status);
900+
break;
889901
}
890902
}
891903

892-
release_nvm:
893904
i40e_release_nvm(hw);
894905
memcpy(bytes, (u8 *)eeprom_buff, eeprom->len);
895906
free_buff:
@@ -917,6 +928,7 @@ static int i40e_set_eeprom(struct net_device *netdev,
917928
struct i40e_netdev_priv *np = netdev_priv(netdev);
918929
struct i40e_hw *hw = &np->vsi->back->hw;
919930
struct i40e_pf *pf = np->vsi->back;
931+
struct i40e_nvm_access *cmd;
920932
int ret_val = 0;
921933
int errno;
922934
u32 magic;
@@ -934,12 +946,14 @@ static int i40e_set_eeprom(struct net_device *netdev,
934946
test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state))
935947
return -EBUSY;
936948

937-
ret_val = i40e_nvmupd_command(hw, (struct i40e_nvm_access *)eeprom,
938-
bytes, &errno);
939-
if (ret_val)
949+
cmd = (struct i40e_nvm_access *)eeprom;
950+
ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno);
951+
if (ret_val && hw->aq.asq_last_status != I40E_AQ_RC_EBUSY)
940952
dev_info(&pf->pdev->dev,
941-
"NVMUpdate write failed err=%d status=0x%x\n",
942-
ret_val, hw->aq.asq_last_status);
953+
"NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n",
954+
ret_val, hw->aq.asq_last_status, errno,
955+
(u8)(cmd->config & I40E_NVM_MOD_PNT_MASK),
956+
cmd->offset, cmd->data_size);
943957

944958
return errno;
945959
}
@@ -1393,6 +1407,9 @@ static int i40e_eeprom_test(struct net_device *netdev, u64 *data)
13931407
netif_info(pf, hw, netdev, "eeprom test\n");
13941408
*data = i40e_diag_eeprom_test(&pf->hw);
13951409

1410+
/* forcebly clear the NVM Update state machine */
1411+
pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT;
1412+
13961413
return *data;
13971414
}
13981415

0 commit comments

Comments
 (0)