* [net-next 05/13] i40e: add range check to i40e_aq_rc_to_posix
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Just to be sure, add a range check to avoid any possible
array index-out-of-bound issues.
Change-ID: I9323bee6732c2a47599816e1d6c6b3a1f8dcbf54
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_adminq.h | 2 ++
drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index 618fe96..4064b1e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
-EFBIG, /* I40E_AQ_RC_EFBIG */
};
+ if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
+ return -ERANGE;
return aq_to_posix[aq_rc];
}
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
index d5d3c93..4d63514 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
@@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
-EFBIG, /* I40E_AQ_RC_EFBIG */
};
+ if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
+ return -ERANGE;
return aq_to_posix[aq_rc];
}
--
1.9.3
^ permalink raw reply related
* [net-next 04/13] i40e: rework debug messages for NVM update
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Rework the debug messages in the NVM update state machine so that we can
turn them on and off dynamically rather than forcing a recompile/reload.
These can now be turned on with something like:
ethtool -s eth1 msglvl 0xf000008f
and off with:
ethtool -s eth1 msglvl 0xf000000f
The high 0xf0000000 gets the driver's attention that we want to change the
internal debug flags, and the 0x80 bit is the NVM debug.
Change-ID: I5efb9039400304b29a0fd6ddea3f47bb362e6661
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Greg Rose <gregory.v.rose@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 107 +++++++++++++++++++++--------
1 file changed, 80 insertions(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 25c4f9a..df429bb 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -61,7 +61,7 @@ i40e_status i40e_init_nvm(struct i40e_hw *hw)
} else { /* Blank programming mode */
nvm->blank_nvm_mode = true;
ret_code = I40E_ERR_NVM_BLANK_MODE;
- hw_dbg(hw, "NVM init error: unsupported blank mode.\n");
+ i40e_debug(hw, I40E_DEBUG_NVM, "NVM init error: unsupported blank mode.\n");
}
return ret_code;
@@ -118,8 +118,9 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
hw->nvm.hw_semaphore_timeout = 0;
hw->nvm.hw_semaphore_wait =
I40E_MS_TO_GTIME(time) + gtime;
- hw_dbg(hw, "NVM acquire timed out, wait %llu ms before trying again.\n",
- time);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM acquire timed out, wait %llu ms before trying again.\n",
+ time);
}
}
@@ -160,7 +161,7 @@ static i40e_status i40e_poll_sr_srctl_done_bit(struct i40e_hw *hw)
udelay(5);
}
if (ret_code == I40E_ERR_TIMEOUT)
- hw_dbg(hw, "Done bit in GLNVM_SRCTL not set\n");
+ i40e_debug(hw, I40E_DEBUG_NVM, "Done bit in GLNVM_SRCTL not set");
return ret_code;
}
@@ -179,7 +180,9 @@ i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
u32 sr_reg;
if (offset >= hw->nvm.sr_size) {
- hw_dbg(hw, "NVM read error: Offset beyond Shadow RAM limit.\n");
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM read error: offset %d beyond Shadow RAM limit %d\n",
+ offset, hw->nvm.sr_size);
ret_code = I40E_ERR_PARAM;
goto read_nvm_exit;
}
@@ -202,8 +205,9 @@ i40e_status i40e_read_nvm_word(struct i40e_hw *hw, u16 offset,
}
}
if (ret_code)
- hw_dbg(hw, "NVM read error: Couldn't access Shadow RAM address: 0x%x\n",
- offset);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM read error: Couldn't access Shadow RAM address: 0x%x\n",
+ offset);
read_nvm_exit:
return ret_code;
@@ -263,14 +267,20 @@ static i40e_status i40e_write_nvm_aq(struct i40e_hw *hw, u8 module_pointer,
* Firmware will check the module-based model.
*/
if ((offset + words) > hw->nvm.sr_size)
- hw_dbg(hw, "NVM write error: offset beyond Shadow RAM limit.\n");
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM write error: offset %d beyond Shadow RAM limit %d\n",
+ (offset + words), hw->nvm.sr_size);
else if (words > I40E_SR_SECTOR_SIZE_IN_WORDS)
/* We can write only up to 4KB (one sector), in one AQ write */
- hw_dbg(hw, "NVM write fail error: cannot write more than 4KB in a single write.\n");
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM write fail error: tried to write %d words, limit is %d.\n",
+ words, I40E_SR_SECTOR_SIZE_IN_WORDS);
else if (((offset + (words - 1)) / I40E_SR_SECTOR_SIZE_IN_WORDS)
!= (offset / I40E_SR_SECTOR_SIZE_IN_WORDS))
/* A single write cannot spread over two sectors */
- hw_dbg(hw, "NVM write error: cannot spread over two sectors in a single write.\n");
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM write error: cannot spread over two sectors in a single write offset=%d words=%d\n",
+ offset, words);
else
ret_code = i40e_aq_update_nvm(hw, module_pointer,
2 * offset, /*bytes*/
@@ -438,6 +448,22 @@ static inline u8 i40e_nvmupd_get_transaction(u32 val)
return (u8)((val & I40E_NVM_TRANS_MASK) >> I40E_NVM_TRANS_SHIFT);
}
+static char *i40e_nvm_update_state_str[] = {
+ "I40E_NVMUPD_INVALID",
+ "I40E_NVMUPD_READ_CON",
+ "I40E_NVMUPD_READ_SNT",
+ "I40E_NVMUPD_READ_LCB",
+ "I40E_NVMUPD_READ_SA",
+ "I40E_NVMUPD_WRITE_ERA",
+ "I40E_NVMUPD_WRITE_CON",
+ "I40E_NVMUPD_WRITE_SNT",
+ "I40E_NVMUPD_WRITE_LCB",
+ "I40E_NVMUPD_WRITE_SA",
+ "I40E_NVMUPD_CSUM_CON",
+ "I40E_NVMUPD_CSUM_SA",
+ "I40E_NVMUPD_CSUM_LCB",
+};
+
/**
* i40e_nvmupd_command - Process an NVM update command
* @hw: pointer to hardware structure
@@ -471,6 +497,8 @@ i40e_status i40e_nvmupd_command(struct i40e_hw *hw,
default:
/* invalid state, should never happen */
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVMUPD: no such state %d\n", hw->nvmupd_state);
status = I40E_NOT_SUPPORTED;
*errno = -ESRCH;
break;
@@ -572,6 +600,9 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
break;
default:
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVMUPD: bad cmd %s in init state\n",
+ i40e_nvm_update_state_str[upd_cmd]);
status = I40E_ERR_NVM;
*errno = -ESRCH;
break;
@@ -611,6 +642,9 @@ static i40e_status i40e_nvmupd_state_reading(struct i40e_hw *hw,
break;
default:
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVMUPD: bad cmd %s in reading state.\n",
+ i40e_nvm_update_state_str[upd_cmd]);
status = I40E_NOT_SUPPORTED;
*errno = -ESRCH;
break;
@@ -671,6 +705,9 @@ static i40e_status i40e_nvmupd_state_writing(struct i40e_hw *hw,
break;
default:
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVMUPD: bad cmd %s in writing state.\n",
+ i40e_nvm_update_state_str[upd_cmd]);
status = I40E_NOT_SUPPORTED;
*errno = -ESRCH;
break;
@@ -702,8 +739,9 @@ static enum i40e_nvmupd_cmd i40e_nvmupd_validate_command(struct i40e_hw *hw,
/* limits on data size */
if ((cmd->data_size < 1) ||
(cmd->data_size > I40E_NVMUPD_MAX_DATA)) {
- hw_dbg(hw, "i40e_nvmupd_validate_command data_size %d\n",
- cmd->data_size);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_validate_command data_size %d\n",
+ cmd->data_size);
*errno = -EFAULT;
return I40E_NVMUPD_INVALID;
}
@@ -755,12 +793,14 @@ static enum i40e_nvmupd_cmd i40e_nvmupd_validate_command(struct i40e_hw *hw,
}
break;
}
+ i40e_debug(hw, I40E_DEBUG_NVM, "%s\n",
+ i40e_nvm_update_state_str[upd_cmd]);
if (upd_cmd == I40E_NVMUPD_INVALID) {
*errno = -EFAULT;
- hw_dbg(hw,
- "i40e_nvmupd_validate_command returns %d errno: %d\n",
- upd_cmd, *errno);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_validate_command returns %d errno %d\n",
+ upd_cmd, *errno);
}
return upd_cmd;
}
@@ -785,14 +825,18 @@ static i40e_status i40e_nvmupd_nvm_read(struct i40e_hw *hw,
transaction = i40e_nvmupd_get_transaction(cmd->config);
module = i40e_nvmupd_get_module(cmd->config);
last = (transaction == I40E_NVM_LCB) || (transaction == I40E_NVM_SA);
- hw_dbg(hw, "i40e_nvmupd_nvm_read mod 0x%x off 0x%x len 0x%x\n",
- module, cmd->offset, cmd->data_size);
status = i40e_aq_read_nvm(hw, module, cmd->offset, (u16)cmd->data_size,
bytes, last, NULL);
- hw_dbg(hw, "i40e_nvmupd_nvm_read status %d\n", status);
- if (status)
+ if (status) {
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_read mod 0x%x off 0x%x len 0x%x\n",
+ module, cmd->offset, cmd->data_size);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_read status %d aq %d\n",
+ status, hw->aq.asq_last_status);
*errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ }
return status;
}
@@ -816,13 +860,17 @@ static i40e_status i40e_nvmupd_nvm_erase(struct i40e_hw *hw,
transaction = i40e_nvmupd_get_transaction(cmd->config);
module = i40e_nvmupd_get_module(cmd->config);
last = (transaction & I40E_NVM_LCB);
- hw_dbg(hw, "i40e_nvmupd_nvm_erase mod 0x%x off 0x%x len 0x%x\n",
- module, cmd->offset, cmd->data_size);
status = i40e_aq_erase_nvm(hw, module, cmd->offset, (u16)cmd->data_size,
last, NULL);
- hw_dbg(hw, "i40e_nvmupd_nvm_erase status %d\n", status);
- if (status)
+ if (status) {
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_erase mod 0x%x off 0x%x len 0x%x\n",
+ module, cmd->offset, cmd->data_size);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_erase status %d aq %d\n",
+ status, hw->aq.asq_last_status);
*errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ }
return status;
}
@@ -847,13 +895,18 @@ static i40e_status i40e_nvmupd_nvm_write(struct i40e_hw *hw,
transaction = i40e_nvmupd_get_transaction(cmd->config);
module = i40e_nvmupd_get_module(cmd->config);
last = (transaction & I40E_NVM_LCB);
- hw_dbg(hw, "i40e_nvmupd_nvm_write mod 0x%x off 0x%x len 0x%x\n",
- module, cmd->offset, cmd->data_size);
+
status = i40e_aq_update_nvm(hw, module, cmd->offset,
(u16)cmd->data_size, bytes, last, NULL);
- hw_dbg(hw, "i40e_nvmupd_nvm_write status %d\n", status);
- if (status)
+ if (status) {
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_write mod 0x%x off 0x%x len 0x%x\n",
+ module, cmd->offset, cmd->data_size);
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "i40e_nvmupd_nvm_write status %d aq %d\n",
+ status, hw->aq.asq_last_status);
*errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ }
return status;
}
--
1.9.3
^ permalink raw reply related
* [net-next 06/13] i40e: init NVM update state on adminq init
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
The adminq init is run after the EMPR that is triggered by the
NVM update. The final write command will cause the reset and
will want to wait for the ARQ event that signals the end of the
update, but the reset precludes the event being sent. The state
is probably already at INIT, but we set it so here anyway, and
clear the release_on_done flag as well.
Change-ID: Ie9d724a39e71f988741abc3d51b4cb198c7e0272
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
Acked-by: Kamil Krawczyk <kamil.krawczyk@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_adminq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.c b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
index ebff11b..77f6254 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.c
@@ -617,6 +617,8 @@ i40e_status i40e_init_adminq(struct i40e_hw *hw)
/* pre-emptive resource lock release */
i40e_aq_release_resource(hw, I40E_NVM_RESOURCE_ID, 0, NULL);
+ hw->aq.nvm_release_on_done = false;
+ hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
ret_code = i40e_aq_set_hmc_resource_profile(hw,
I40E_HMC_PROFILE_DEFAULT,
--
1.9.3
^ permalink raw reply related
* [net-next 07/13] i40e: remove unused nvm_semaphore_wait
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
The nvm_semaphore_wait field is set but never used, so let's
just get rid of it.
Change-ID: I2107bd29b69f99b1a61d7591d087429527c9d8fa
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 2 --
drivers/net/ethernet/intel/i40e/i40e_type.h | 1 -
drivers/net/ethernet/intel/i40evf/i40e_type.h | 1 -
3 files changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index df429bb..37f0f5f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -116,8 +116,6 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
}
if (ret_code) {
hw->nvm.hw_semaphore_timeout = 0;
- hw->nvm.hw_semaphore_wait =
- I40E_MS_TO_GTIME(time) + gtime;
i40e_debug(hw, I40E_DEBUG_NVM,
"NVM acquire timed out, wait %llu ms before trying again.\n",
time);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 3904dd8..306a23a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -262,7 +262,6 @@ enum i40e_aq_resource_access_type {
struct i40e_nvm_info {
u64 hw_semaphore_timeout; /* 2usec global time (GTIME resolution) */
- u64 hw_semaphore_wait; /* - || - */
u32 timeout; /* [ms] */
u16 sr_size; /* Shadow RAM size in words */
bool blank_nvm_mode; /* is NVM empty (no FW present)*/
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_type.h b/drivers/net/ethernet/intel/i40evf/i40e_type.h
index 77abe17..9d472d6 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_type.h
@@ -261,7 +261,6 @@ enum i40e_aq_resource_access_type {
struct i40e_nvm_info {
u64 hw_semaphore_timeout; /* 2usec global time (GTIME resolution) */
- u64 hw_semaphore_wait; /* - || - */
u32 timeout; /* [ms] */
u16 sr_size; /* Shadow RAM size in words */
bool blank_nvm_mode; /* is NVM empty (no FW present)*/
--
1.9.3
^ permalink raw reply related
* [net-next 08/13] i40e: set max limit for access polling
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Don't bother trying to set a smaller timeout on the polling,
just simplify the code and always use the max limit. Also,
rename a variable for clarity and fix a comment.
Change-ID: I0300c3562ccc4fd5fa3088f8ae52db0c1eb33af5
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 21 ++++++++-------------
drivers/net/ethernet/intel/i40e/i40e_type.h | 2 +-
drivers/net/ethernet/intel/i40evf/i40e_type.h | 2 +-
3 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 37f0f5f..f55e52b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -80,45 +80,40 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
{
i40e_status ret_code = 0;
u64 gtime, timeout;
- u64 time = 0;
+ u64 time_left = 0;
if (hw->nvm.blank_nvm_mode)
goto i40e_i40e_acquire_nvm_exit;
ret_code = i40e_aq_request_resource(hw, I40E_NVM_RESOURCE_ID, access,
- 0, &time, NULL);
+ 0, &time_left, NULL);
/* Reading the Global Device Timer */
gtime = rd32(hw, I40E_GLVFGEN_TIMER);
/* Store the timeout */
- hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time) + gtime;
+ hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time_left) + gtime;
if (ret_code) {
- /* Set the polling timeout */
- if (time > I40E_MAX_NVM_TIMEOUT)
- timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT)
- + gtime;
- else
- timeout = hw->nvm.hw_semaphore_timeout;
/* Poll until the current NVM owner timeouts */
+ timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) + gtime;
while (gtime < timeout) {
usleep_range(10000, 20000);
+ gtime = rd32(hw, I40E_GLVFGEN_TIMER);
ret_code = i40e_aq_request_resource(hw,
I40E_NVM_RESOURCE_ID,
- access, 0, &time,
+ access, 0, &time_left,
NULL);
if (!ret_code) {
hw->nvm.hw_semaphore_timeout =
- I40E_MS_TO_GTIME(time) + gtime;
+ I40E_MS_TO_GTIME(time_left) + gtime;
break;
}
- gtime = rd32(hw, I40E_GLVFGEN_TIMER);
}
if (ret_code) {
hw->nvm.hw_semaphore_timeout = 0;
i40e_debug(hw, I40E_DEBUG_NVM,
"NVM acquire timed out, wait %llu ms before trying again.\n",
- time);
+ time_left);
}
}
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 306a23a..844421f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -261,7 +261,7 @@ enum i40e_aq_resource_access_type {
};
struct i40e_nvm_info {
- u64 hw_semaphore_timeout; /* 2usec global time (GTIME resolution) */
+ u64 hw_semaphore_timeout; /* usec global time (GTIME resolution) */
u32 timeout; /* [ms] */
u16 sr_size; /* Shadow RAM size in words */
bool blank_nvm_mode; /* is NVM empty (no FW present)*/
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_type.h b/drivers/net/ethernet/intel/i40evf/i40e_type.h
index 9d472d6..d8175cd 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_type.h
@@ -260,7 +260,7 @@ enum i40e_aq_resource_access_type {
};
struct i40e_nvm_info {
- u64 hw_semaphore_timeout; /* 2usec global time (GTIME resolution) */
+ u64 hw_semaphore_timeout; /* usec global time (GTIME resolution) */
u32 timeout; /* [ms] */
u16 sr_size; /* Shadow RAM size in words */
bool blank_nvm_mode; /* is NVM empty (no FW present)*/
--
1.9.3
^ permalink raw reply related
* [net-next 09/13] i40e: fix up NVM update sm error handling
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
The state transitions after an error were not managed well, so
these changes get us back to the INIT state or don't transition
out of the INIT state after most errors.
Change-ID: I90aa0e4e348dc4f58cbcdce9c5d4b7fd35981c6c
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index f55e52b..f3d1c85 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -535,7 +535,10 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
*errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_read(hw, cmd, bytes, errno);
- hw->nvmupd_state = I40E_NVMUPD_STATE_READING;
+ if (status)
+ i40e_release_nvm(hw);
+ else
+ hw->nvmupd_state = I40E_NVMUPD_STATE_READING;
}
break;
@@ -571,7 +574,10 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
*errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_write(hw, cmd, bytes, errno);
- hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
+ if (status)
+ i40e_release_nvm(hw);
+ else
+ hw->nvmupd_state = I40E_NVMUPD_STATE_WRITING;
}
break;
@@ -671,30 +677,30 @@ static i40e_status i40e_nvmupd_state_writing(struct i40e_hw *hw,
case I40E_NVMUPD_WRITE_LCB:
status = i40e_nvmupd_nvm_write(hw, cmd, bytes, errno);
- if (!status) {
+ if (!status)
hw->aq.nvm_release_on_done = true;
- hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
- }
+ hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
break;
case I40E_NVMUPD_CSUM_CON:
status = i40e_update_nvm_checksum(hw);
- if (status)
+ if (status) {
*errno = hw->aq.asq_last_status ?
i40e_aq_rc_to_posix(hw->aq.asq_last_status) :
-EIO;
+ hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
+ }
break;
case I40E_NVMUPD_CSUM_LCB:
status = i40e_update_nvm_checksum(hw);
- if (status) {
+ if (status)
*errno = hw->aq.asq_last_status ?
i40e_aq_rc_to_posix(hw->aq.asq_last_status) :
-EIO;
- } else {
+ else
hw->aq.nvm_release_on_done = true;
- hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
- }
+ hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
break;
default:
--
1.9.3
^ permalink raw reply related
* [net-next 10/13] i40e: poll on NVM semaphore only if not other error
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Only poll on the NVM semaphore if there's time left on a previous
reservation. Also, add a little more info to debug messages.
Change-ID: I2439bf870b95a28b810dcb5cca1c06440463cf8a
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index f3d1c85..0fc62fc 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -93,10 +93,15 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
/* Store the timeout */
hw->nvm.hw_semaphore_timeout = I40E_MS_TO_GTIME(time_left) + gtime;
- if (ret_code) {
+ if (ret_code)
+ i40e_debug(hw, I40E_DEBUG_NVM,
+ "NVM acquire type %d failed time_left=%llu ret=%d aq_err=%d\n",
+ access, time_left, ret_code, hw->aq.asq_last_status);
+
+ if (ret_code && time_left) {
/* Poll until the current NVM owner timeouts */
timeout = I40E_MS_TO_GTIME(I40E_MAX_NVM_TIMEOUT) + gtime;
- while (gtime < timeout) {
+ while ((gtime < timeout) && time_left) {
usleep_range(10000, 20000);
gtime = rd32(hw, I40E_GLVFGEN_TIMER);
ret_code = i40e_aq_request_resource(hw,
@@ -112,8 +117,8 @@ i40e_status i40e_acquire_nvm(struct i40e_hw *hw,
if (ret_code) {
hw->nvm.hw_semaphore_timeout = 0;
i40e_debug(hw, I40E_DEBUG_NVM,
- "NVM acquire timed out, wait %llu ms before trying again.\n",
- time_left);
+ "NVM acquire timed out, wait %llu ms before trying again. status=%d aq_err=%d\n",
+ time_left, ret_code, hw->aq.asq_last_status);
}
}
--
1.9.3
^ permalink raw reply related
* [net-next 11/13] i40e: check for AQ timeout in aq_rc decode
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Decoding the AQ return code is great except when the AQ send timed out
and there's no return code set. This changes the handy decoder
interface to help catch and properly report the condition as a useful
errno rather than returning a misleading '0'.
Change-ID: I07a1f94f921606da49ffac7837bcdc37cd8222eb
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_adminq.h | 7 +++++-
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 33 ++++++++++++++++---------
drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 7 +++++-
3 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index 4064b1e..5c3d435 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -28,6 +28,7 @@
#define _I40E_ADMINQ_H_
#include "i40e_osdep.h"
+#include "i40e_status.h"
#include "i40e_adminq_cmd.h"
#define I40E_ADMINQ_DESC(R, i) \
@@ -108,7 +109,7 @@ struct i40e_adminq_info {
* i40e_aq_rc_to_posix - convert errors to user-land codes
* aq_rc: AdminQ error code to convert
**/
-static inline int i40e_aq_rc_to_posix(u16 aq_rc)
+static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
{
int aq_to_posix[] = {
0, /* I40E_AQ_RC_OK */
@@ -136,6 +137,10 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
-EFBIG, /* I40E_AQ_RC_EFBIG */
};
+ /* aq_rc is invalid if AQ timed out */
+ if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
+ return -EAGAIN;
+
if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
return -ERANGE;
return aq_to_posix[aq_rc];
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 0fc62fc..1613ef4 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -527,7 +527,8 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_READ_SA:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_read(hw, cmd, bytes, errno);
i40e_release_nvm(hw);
@@ -537,7 +538,8 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_READ_SNT:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_READ);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_read(hw, cmd, bytes, errno);
if (status)
@@ -550,7 +552,8 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_WRITE_ERA:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_erase(hw, cmd, errno);
if (status)
@@ -563,7 +566,8 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_WRITE_SA:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_write(hw, cmd, bytes, errno);
if (status)
@@ -576,7 +580,8 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_WRITE_SNT:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_nvmupd_nvm_write(hw, cmd, bytes, errno);
if (status)
@@ -589,12 +594,14 @@ static i40e_status i40e_nvmupd_state_init(struct i40e_hw *hw,
case I40E_NVMUPD_CSUM_SA:
status = i40e_acquire_nvm(hw, I40E_RESOURCE_WRITE);
if (status) {
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status);
} else {
status = i40e_update_nvm_checksum(hw);
if (status) {
*errno = hw->aq.asq_last_status ?
- i40e_aq_rc_to_posix(hw->aq.asq_last_status) :
+ i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status) :
-EIO;
i40e_release_nvm(hw);
} else {
@@ -691,7 +698,8 @@ static i40e_status i40e_nvmupd_state_writing(struct i40e_hw *hw,
status = i40e_update_nvm_checksum(hw);
if (status) {
*errno = hw->aq.asq_last_status ?
- i40e_aq_rc_to_posix(hw->aq.asq_last_status) :
+ i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status) :
-EIO;
hw->nvmupd_state = I40E_NVMUPD_STATE_INIT;
}
@@ -701,7 +709,8 @@ static i40e_status i40e_nvmupd_state_writing(struct i40e_hw *hw,
status = i40e_update_nvm_checksum(hw);
if (status)
*errno = hw->aq.asq_last_status ?
- i40e_aq_rc_to_posix(hw->aq.asq_last_status) :
+ i40e_aq_rc_to_posix(status,
+ hw->aq.asq_last_status) :
-EIO;
else
hw->aq.nvm_release_on_done = true;
@@ -839,7 +848,7 @@ static i40e_status i40e_nvmupd_nvm_read(struct i40e_hw *hw,
i40e_debug(hw, I40E_DEBUG_NVM,
"i40e_nvmupd_nvm_read status %d aq %d\n",
status, hw->aq.asq_last_status);
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status);
}
return status;
@@ -873,7 +882,7 @@ static i40e_status i40e_nvmupd_nvm_erase(struct i40e_hw *hw,
i40e_debug(hw, I40E_DEBUG_NVM,
"i40e_nvmupd_nvm_erase status %d aq %d\n",
status, hw->aq.asq_last_status);
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status);
}
return status;
@@ -909,7 +918,7 @@ static i40e_status i40e_nvmupd_nvm_write(struct i40e_hw *hw,
i40e_debug(hw, I40E_DEBUG_NVM,
"i40e_nvmupd_nvm_write status %d aq %d\n",
status, hw->aq.asq_last_status);
- *errno = i40e_aq_rc_to_posix(hw->aq.asq_last_status);
+ *errno = i40e_aq_rc_to_posix(status, hw->aq.asq_last_status);
}
return status;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
index 4d63514..2cae522 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
@@ -28,6 +28,7 @@
#define _I40E_ADMINQ_H_
#include "i40e_osdep.h"
+#include "i40e_status.h"
#include "i40e_adminq_cmd.h"
#define I40E_ADMINQ_DESC(R, i) \
@@ -108,7 +109,7 @@ struct i40e_adminq_info {
* i40e_aq_rc_to_posix - convert errors to user-land codes
* aq_rc: AdminQ error code to convert
**/
-static inline int i40e_aq_rc_to_posix(u16 aq_rc)
+static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
{
int aq_to_posix[] = {
0, /* I40E_AQ_RC_OK */
@@ -136,6 +137,10 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
-EFBIG, /* I40E_AQ_RC_EFBIG */
};
+ /* aq_rc is invalid if AQ timed out */
+ if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
+ return -EAGAIN;
+
if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
return -ERANGE;
return aq_to_posix[aq_rc];
--
1.9.3
^ permalink raw reply related
* [net-next 12/13] i40e: add to NVM update debug message
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene, Jeff Kirsher
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
From: Shannon Nelson <shannon.nelson@intel.com>
Add a little more state context to an NVM update debug message.
Change-ID: I512160259052bcdbe5bdf1adf403ab2bf7984970
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Acked-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_nvm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 1613ef4..3e70f2e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -806,8 +806,10 @@ static enum i40e_nvmupd_cmd i40e_nvmupd_validate_command(struct i40e_hw *hw,
}
break;
}
- i40e_debug(hw, I40E_DEBUG_NVM, "%s\n",
- i40e_nvm_update_state_str[upd_cmd]);
+ i40e_debug(hw, I40E_DEBUG_NVM, "%s state %d nvm_release_on_hold %d\n",
+ i40e_nvm_update_state_str[upd_cmd],
+ hw->nvmupd_state,
+ hw->aq.nvm_release_on_done);
if (upd_cmd == I40E_NVMUPD_INVALID) {
*errno = -EFAULT;
--
1.9.3
^ permalink raw reply related
* [net-next 13/13] i40e/i40evf: Convert macro to static inline
From: Jeff Kirsher @ 2014-12-09 11:22 UTC (permalink / raw)
To: davem; +Cc: Jeff Kirsher, netdev, nhorman, sassmann, jogreene
In-Reply-To: <1418124170-7495-1-git-send-email-jeffrey.t.kirsher@intel.com>
Inline functions are preferred over macros when they can be used
interchangeably.
Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/ethernet/intel/i40e/i40e_type.h | 5 ++++-
drivers/net/ethernet/intel/i40evf/i40e_type.h | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
index 844421f..618cce2 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
@@ -481,7 +481,10 @@ struct i40e_hw {
u32 debug_mask;
};
-#define i40e_is_vf(_hw) ((_hw)->mac.type == I40E_MAC_VF)
+static inline bool i40e_is_vf(struct i40e_hw *hw)
+{
+ return (hw->mac.type == I40E_MAC_VF);
+}
struct i40e_driver_version {
u8 major_version;
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_type.h b/drivers/net/ethernet/intel/i40evf/i40e_type.h
index d8175cd..6b6fcf6 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_type.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_type.h
@@ -475,7 +475,10 @@ struct i40e_hw {
u32 debug_mask;
};
-#define i40e_is_vf(_hw) ((_hw)->mac.type == I40E_MAC_VF)
+static inline bool i40e_is_vf(struct i40e_hw *hw)
+{
+ return (hw->mac.type == I40E_MAC_VF);
+}
struct i40e_driver_version {
u8 major_version;
--
1.9.3
^ permalink raw reply related
* [PATCH] netback: don't store invalid vif pointer
From: Jan Beulich @ 2014-12-09 11:47 UTC (permalink / raw)
To: Wei Liu, Ian Campbell; +Cc: xen-devel, netdev
When xenvif_alloc() fails, it returns a non-NULL error indicator. To
avoid eventual races, we shouldn't store that into struct backend_info
as readers of it only check for NULL.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -404,6 +404,7 @@ static int backend_create_xenvif(struct
int err;
long handle;
struct xenbus_device *dev = be->dev;
+ struct xenvif *vif;
if (be->vif != NULL)
return 0;
@@ -414,13 +415,13 @@ static int backend_create_xenvif(struct
return (err < 0) ? err : -EINVAL;
}
- be->vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
- if (IS_ERR(be->vif)) {
- err = PTR_ERR(be->vif);
- be->vif = NULL;
+ vif = xenvif_alloc(&dev->dev, dev->otherend_id, handle);
+ if (IS_ERR(vif)) {
+ err = PTR_ERR(vif);
xenbus_dev_fatal(dev, err, "creating interface");
return err;
}
+ be->vif = vif;
kobject_uevent(&dev->dev.kobj, KOBJ_ONLINE);
return 0;
^ permalink raw reply
* Re: [patch net-next v3 02/17] net: make vid as a parameter for ndo_fdb_add/ndo_fdb_del
From: Or Gerlitz @ 2014-12-09 11:57 UTC (permalink / raw)
To: John Fastabend, Jiří Pírko; +Cc: Linux Netdev List
In-Reply-To: <5474A391.2080204@gmail.com>
On Tue, Nov 25, 2014 at 5:43 PM, John Fastabend
<john.fastabend@gmail.com> wrote:
> On 11/25/2014 07:18 AM, Jiri Pirko wrote:
>>
>> Tue, Nov 25, 2014 at 04:13:12PM CET, gospo@cumulusnetworks.com wrote:
>>>
>>> On Tue, Nov 25, 2014 at 11:28:33AM +0100, Jiri Pirko wrote:
>>>>
>>>> Do the work of parsing NDA_VLAN directly in rtnetlink code, pass simple
>>>> u16 vid to drivers from there.
>>>>
>>>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>>>
>>>
>>> Structurally this looks fine, just a misspelling noted below.
>>>
>>> Acked-by: Andy Gospodarek <gospo@cumulusnetworks.com>
>>>
>
> If your going to spin this, should we return an error from
> ndo_dflt_fdb_add() when we have a non-zero vid? The dflt
> handler uses the dev_(mc|uc)_add_excl routines which will
> not consume vids.
so... was this comment addressed along the discussion? I see in the
code that we don't check
on the _dflt_ handlers nor on the per device ones (ixgbe, i40e, qlgc)
for a valid VID and return
error on that.
> If you want to address this with a follow up patch I'm OK
> with that. Go ahead and add my ack,
^ permalink raw reply
* PROBLEM: bonding status file in /proc not removed when using bond-device as a slave
From: Peter Schmitt @ 2014-12-09 12:04 UTC (permalink / raw)
To: netdev
Hi everyone,
I want to create a master-backup bond that has two LACP bonds as slaves. Both
LACP slaves should be connected to different switches so that I have
connectivity even if one switch fails.
While experimenting with this setup on the recent LTS kernel 3.14.26 I have found the following behaviour:
When I add a bond device (by default an LACP bond, mode 4) to a master-backup
bond (mode 1) and then remove it, the corresponding status file for the bond remains in
/proc/net/bonding/ and when I do a cat on this file, the machine crashes or I get a
general protection fault.
The following snippet creates such a scenario:
#!/bin/bash
echo +bond1 > /sys/class/net/bonding_masters
echo 1 > /sys/class/net/bond1/bonding/mode
echo +bond2 > /sys/class/net/bonding_masters
echo +bond2 > /sys/class/net/bond1/bonding/slaves
echo -bond2 > /sys/class/net/bond1/bonding/slaves
echo -bond2 > /sys/class/net/bonding_masters
After this is executed, the file /proc/net/bonding/bond2 still exists
while /sys/class/net/bonding_masters only shows bond1:
> ls -lah /proc/net/bonding/bond*
r--r--r-- 1 root root 0 Dec 8 16:53 /proc/net/bonding/bond1
r--r--r-- 1 root root 0 Dec 8 16:53 /proc/net/bonding/bond2
> cat /sys/class/net/bonding_masters
bond1
When I now make a "cat" on the file in /proc, I get a general protection fault
or even worse, the machine just crashes and is unresponsive and it can only be
fixed with a power-cycle.
> uname -a
Linux bondingtest 3.14.26-x86 #1 SMP Sun Dec 7 11:29:36 CET 2014 i686 GNU/Linux
The bonding module is loaded with the following options:
modprobe bonding miimon=100 max_bonds=0 mode=4 lacp_rate=1 xmit_hash_policy=layer2+3
> cat /proc/net/bonding/bond2
general protection fault: 0000 [#1] SMP·
Modules linked in: w83627hf hwmon_vid coretemp hwmon ip_set iptable_nat nf_nat_ipv4 ipt_REJECT nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_nat nf_conntrack_ftp msr ipmi_devintf ipmi_msghandler ip_gre gre bonding pcspkr i3200_edac edac_core uhci_hcd ehci_pci ehci_hcd lpc_ich mfd_core pata_acpi ata_generic shpchp e1000e ptp pps_core [last unloaded: cpuid]
CPU: 0 PID: 31747 Comm: cat Not tainted 3.14.26-x86_64 #1
Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015 06/29/2009
task: ffff8800d61d77b0 ti: ffff8800d6068000 task.ti: ffff8800d6068000
RIP: 0010:[<ffffffffc00f7ef0>] [<ffffffffc00f7ef0>] bond_info_seq_show+0x2d0/0x5e0 [bonding]
RSP: 0018:ffff8800d6069e08 EFLAGS: 00010212
RAX: 5f7367705f656c62 RBX: ffff880198570380 RCX: 0000000000000001
RDX: ffffffffc00f9547 RSI: ffffffffc00f954f RDI: ffff880198570380
RBP: ffff8800d6069e48 R08: ffffffff9413ed60 R09: ffff8800dba15cd4
R10: 0000000000000001 R11: 0000000000000000 R12: ffff8800d60917c0
R13: 656b636f6c6e756d R14: ffff880197d469c0 R15: ffff8800d6069e90
FS: 0000000000000000(0000) GS:ffff88019fc00000(0063) knlGS:00000000f761c8d0
CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b
CR2: 000000000804ce10 CR3: 00000000db8cd000 CR4: 00000000000407f0
Stack:
ffff8800d6069e48 ffffffffc00f8318 ffff8801986ba9f0 ffff880197d469c0
ffff880198570380 0000000000000001 ffff880197d469c0 ffff8800d6069e90
ffff8800d6069ec8 ffffffff9413eed1 ffff880198289a58 0000000008213000
Call Trace:
[<ffffffffc00f8318>] ? bond_info_seq_start+0x28/0xa8 [bonding]
[<ffffffff9413eed1>] seq_read+0x171/0x3f0
[<ffffffff94175a7e>] proc_reg_read+0x3e/0x70
[<ffffffff9411e0e1>] vfs_read+0xa1/0x160
[<ffffffff9411e281>] SyS_read+0x51/0xc0
[<ffffffff94039c9c>] ? do_page_fault+0xc/0x10
[<ffffffff94516cdf>] sysenter_dispatch+0x7/0x1e
Code: 04 49 8b 55 00 48 c7 c6 2a 95 0f c0 48 89 df 31 c0 e8 d5 6c 04 d4 49 8b 04 24 48 c7 c2 47 95 0f c0 48 c7 c6 4f 95 0f c0 48 89 df <48> 8b 40 48 a8 04 48 c7 c0 4c 95 0f c0 48 0f 44 d0 31 c0 e8 a8·
RIP [<ffffffffc00f7ef0>] bond_info_seq_show+0x2d0/0x5e0 [bonding]
RSP <ffff8800d6069e08>
---[ end trace 96fae3d9de6068c7 ]---
Segmentation fault
ver_linux:
Linux bondingtest 3.14.26-x86 #1 SMP Sun Dec 7 11:29:36 CET 2014 i686 GNU/Linux
Gnu C 4.4.3
Gnu make 3.81
binutils 2.20.1
util-linux 2.17.2
mount support
module-init-tools found
e2fsprogs 1.42.11
PPP 2.4.5
Linux C Library 2.11.1
Dynamic linker (ldd) 2.11.1
Procps 3.2.8
Net-tools 1.60
Kbd 1.15
Sh-utils found
Modules Loaded xt_TPROXY xt_set xt_socket nf_defrag_ipv6 xt_REDIRECT ip_set_hash_ip hwmon_vid hwmon bridge ip_set iptable_nat nf_nat_ipv4 ipt_REJECT nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_nat nf_conntrack_ftp msr ipmi_devintf ipmi_msghandler ip_gre gre bonding pcspkr shpchp uhci_hcd ehci_pci ehci_hcd lpc_ich mfd_core pata_acpi ata_generic
If you have any questions or need more information or tests, I will gladly help you with that.
Thank you in advance.
Best regards,
Peter Schmitt
^ permalink raw reply
* Re: [PATCH] netback: don't store invalid vif pointer
From: Ian Campbell @ 2014-12-09 12:08 UTC (permalink / raw)
To: Jan Beulich; +Cc: Wei Liu, xen-devel, netdev
In-Reply-To: <5486EF48020000780004E1B8@mail.emea.novell.com>
On Tue, 2014-12-09 at 11:47 +0000, Jan Beulich wrote:
> When xenvif_alloc() fails, it returns a non-NULL error indicator. To
> avoid eventual races, we shouldn't store that into struct backend_info
> as readers of it only check for NULL.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Thanks.
^ permalink raw reply
* [PATCH v3] sh_eth: Optimization for RX excess judgement
From: Yoshihiro Kaneko @ 2014-12-09 12:23 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Simon Horman, Magnus Damm, linux-sh
From: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Both of 'boguscnt' and 'quota' have nearly meaning as the condition of
the reception loop.
In order to cut down redundant processing, this patch changes excess
judgement.
Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
This patch is based on net-next tree.
v3 [Yoshihiro Kaneko]
* fixes the calculation error of *quota.
v2 [Yoshihiro Kaneko]
* re-spin for net-next.
* remove unneeded check of "quota".
* remove unneeded incrementation of "boguscnt".
* drop the change of the return statement.
drivers/net/ethernet/renesas/sh_eth.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index dbe8606..f94bbf5 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1394,10 +1394,13 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
int entry = mdp->cur_rx % mdp->num_rx_ring;
int boguscnt = (mdp->dirty_rx + mdp->num_rx_ring) - mdp->cur_rx;
+ int limit;
struct sk_buff *skb;
u16 pkt_len = 0;
u32 desc_status;
+ boguscnt = min(boguscnt, *quota);
+ limit = boguscnt;
rxdesc = &mdp->rx_ring[entry];
while (!(rxdesc->status & cpu_to_edmac(mdp, RD_RACT))) {
desc_status = edmac_to_cpu(mdp, rxdesc->status);
@@ -1406,11 +1409,6 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
if (--boguscnt < 0)
break;
- if (*quota <= 0)
- break;
-
- (*quota)--;
-
if (!(desc_status & RDFEND))
ndev->stats.rx_length_errors++;
@@ -1501,6 +1499,8 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
sh_eth_write(ndev, EDRRR_R, EDRRR);
}
+ *quota -= limit - boguscnt - 1;
+
return *quota <= 0;
}
--
1.9.1
^ permalink raw reply related
* Re: OVS Kernel Datapath development
From: Flavio Leitner @ 2014-12-09 12:52 UTC (permalink / raw)
To: Pravin Shelar; +Cc: netdev, dev@openvswitch.org
In-Reply-To: <CALnjE+rn_Giv+8TM1_E2faBftRkivXMYHcjn-4Eq4Gu15r=CiQ@mail.gmail.com>
On Sun, Dec 07, 2014 at 08:47:22PM -0800, Pravin Shelar wrote:
> Since the beginning OVS kernel datapath development is primarily done
> on external OVS repo. Now we have mostly synced upstream and external
> OVS. So we have decided to change this process. New process is as
> follows.
>
> 1. OVS feature development that involves kernel datapath should be
> done on net-next tree datapath.
> 2. Such feature patch series should be posted on netdev and ovs-dev
> mailing list.
> 3. Once review is done for entire series, kernel and OVS userspace
> patches will be merged in respective repo.
> 4. After the merge developer is suppose to send patches for external
> kernel datapath along with old kernel compatibility code. So that we
> can keep external datapath insync.
This is great! Thanks for changing the development process and
make it official.
Cheers!
fbl
^ permalink raw reply
* Re: ipip6 - integer underrun when handlince icmpv4 unreachable messages
From: Steffen Klassert @ 2014-12-09 13:28 UTC (permalink / raw)
To: Alexander Wetzel; +Cc: netdev, roque, kuznet, r.venning, nate
In-Reply-To: <54808A5C.1050205@web.de>
On Thu, Dec 04, 2014 at 05:22:52PM +0100, Alexander Wetzel wrote:
> Hello,
>
> The patch works for me, thank you very much.
>
> Rejecting the ipv4 tunel packets with icmp unreachable is producing the
> expected "Destination unreachable: Address unreachable" messages for the
> inside ipv6 client and everything works as expected. Without the call in
> sit.c to skb_reset_transport_header.
>
> I'll continue to use the patch on my ipv6 tunnel router but I'm sure it
> works as intended.
>
>
> On 04.12.2014 09:56, Steffen Klassert wrote:
> >
> > I think the easiest is to fix it in _decode_session6().
> > Could you please try the patch below?
> >
> > Subject: [PATCH] xfrm6: Fix transport header offset in _decode_session6.
> >
> > skb->transport_header might not be valid when we do a reverse
> > decode because the ipv6 tunnel error handlers don't update it
> > to the inner transport header. This leads to a wrong offset
> > calculation and to wrong layer 4 informations. We fix this
> > by using the size of the ipv6 header as the first offset.
> >
> > Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Thanks for testing, I've applied this to the ipsec tree now.
^ permalink raw reply
* Re: PROBLEM: bonding status file in /proc not removed when using bond-device as a slave
From: Andy Gospodarek @ 2014-12-09 13:58 UTC (permalink / raw)
To: Peter Schmitt; +Cc: netdev
In-Reply-To: <trinity-cf79e6bc-94ab-403a-9ac6-92f47e5325d2-1418126693738@3capp-gmx-bs71>
On Tue, Dec 09, 2014 at 01:04:53PM +0100, Peter Schmitt wrote:
> Hi everyone,
>
> I want to create a master-backup bond that has two LACP bonds as slaves. Both
There is no reason to do this. The bonding code you are running
supports the ability to connect a single 802.3ad bond to different
switches and should do exactly what you need.
When you put all ports in the same bond you will notice that ports that
go to one switch will be listed with a particular aggregator ID and all
ports going to another switch will have a different aggregator ID. You
will also see that the bond will list only one active aggregator. This
should give you the behaviour you desire.
Additionally look at 'ad_select' option in the bonding documentation to
help tune when you switch from one link to another.
> LACP slaves should be connected to different switches so that I have
> connectivity even if one switch fails.
> While experimenting with this setup on the recent LTS kernel 3.14.26 I have found the following behaviour:
> When I add a bond device (by default an LACP bond, mode 4) to a master-backup
> bond (mode 1) and then remove it, the corresponding status file for the bond remains in
> /proc/net/bonding/ and when I do a cat on this file, the machine crashes or I get a
> general protection fault.
>
> The following snippet creates such a scenario:
>
> #!/bin/bash
> echo +bond1 > /sys/class/net/bonding_masters
> echo 1 > /sys/class/net/bond1/bonding/mode
> echo +bond2 > /sys/class/net/bonding_masters
> echo +bond2 > /sys/class/net/bond1/bonding/slaves
> echo -bond2 > /sys/class/net/bond1/bonding/slaves
> echo -bond2 > /sys/class/net/bonding_masters
>
> After this is executed, the file /proc/net/bonding/bond2 still exists
> while /sys/class/net/bonding_masters only shows bond1:
>
> > ls -lah /proc/net/bonding/bond*
> r--r--r-- 1 root root 0 Dec 8 16:53 /proc/net/bonding/bond1
> r--r--r-- 1 root root 0 Dec 8 16:53 /proc/net/bonding/bond2
>
> > cat /sys/class/net/bonding_masters
> bond1
>
> When I now make a "cat" on the file in /proc, I get a general protection fault
> or even worse, the machine just crashes and is unresponsive and it can only be
> fixed with a power-cycle.
>
> > uname -a
> Linux bondingtest 3.14.26-x86 #1 SMP Sun Dec 7 11:29:36 CET 2014 i686 GNU/Linux
>
> The bonding module is loaded with the following options:
> modprobe bonding miimon=100 max_bonds=0 mode=4 lacp_rate=1 xmit_hash_policy=layer2+3
>
>
> > cat /proc/net/bonding/bond2
> general protection fault: 0000 [#1] SMP·
> Modules linked in: w83627hf hwmon_vid coretemp hwmon ip_set iptable_nat nf_nat_ipv4 ipt_REJECT nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_nat nf_conntrack_ftp msr ipmi_devintf ipmi_msghandler ip_gre gre bonding pcspkr i3200_edac edac_core uhci_hcd ehci_pci ehci_hcd lpc_ich mfd_core pata_acpi ata_generic shpchp e1000e ptp pps_core [last unloaded: cpuid]
> CPU: 0 PID: 31747 Comm: cat Not tainted 3.14.26-x86_64 #1
> Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./To be filled by O.E.M., BIOS 080015 06/29/2009
> task: ffff8800d61d77b0 ti: ffff8800d6068000 task.ti: ffff8800d6068000
> RIP: 0010:[<ffffffffc00f7ef0>] [<ffffffffc00f7ef0>] bond_info_seq_show+0x2d0/0x5e0 [bonding]
> RSP: 0018:ffff8800d6069e08 EFLAGS: 00010212
> RAX: 5f7367705f656c62 RBX: ffff880198570380 RCX: 0000000000000001
> RDX: ffffffffc00f9547 RSI: ffffffffc00f954f RDI: ffff880198570380
> RBP: ffff8800d6069e48 R08: ffffffff9413ed60 R09: ffff8800dba15cd4
> R10: 0000000000000001 R11: 0000000000000000 R12: ffff8800d60917c0
> R13: 656b636f6c6e756d R14: ffff880197d469c0 R15: ffff8800d6069e90
> FS: 0000000000000000(0000) GS:ffff88019fc00000(0063) knlGS:00000000f761c8d0
> CS: 0010 DS: 002b ES: 002b CR0: 000000008005003b
> CR2: 000000000804ce10 CR3: 00000000db8cd000 CR4: 00000000000407f0
> Stack:
> ffff8800d6069e48 ffffffffc00f8318 ffff8801986ba9f0 ffff880197d469c0
> ffff880198570380 0000000000000001 ffff880197d469c0 ffff8800d6069e90
> ffff8800d6069ec8 ffffffff9413eed1 ffff880198289a58 0000000008213000
> Call Trace:
> [<ffffffffc00f8318>] ? bond_info_seq_start+0x28/0xa8 [bonding]
> [<ffffffff9413eed1>] seq_read+0x171/0x3f0
> [<ffffffff94175a7e>] proc_reg_read+0x3e/0x70
> [<ffffffff9411e0e1>] vfs_read+0xa1/0x160
> [<ffffffff9411e281>] SyS_read+0x51/0xc0
> [<ffffffff94039c9c>] ? do_page_fault+0xc/0x10
> [<ffffffff94516cdf>] sysenter_dispatch+0x7/0x1e
> Code: 04 49 8b 55 00 48 c7 c6 2a 95 0f c0 48 89 df 31 c0 e8 d5 6c 04 d4 49 8b 04 24 48 c7 c2 47 95 0f c0 48 c7 c6 4f 95 0f c0 48 89 df <48> 8b 40 48 a8 04 48 c7 c0 4c 95 0f c0 48 0f 44 d0 31 c0 e8 a8·
> RIP [<ffffffffc00f7ef0>] bond_info_seq_show+0x2d0/0x5e0 [bonding]
> RSP <ffff8800d6069e08>
> ---[ end trace 96fae3d9de6068c7 ]---
> Segmentation fault
>
> ver_linux:
> Linux bondingtest 3.14.26-x86 #1 SMP Sun Dec 7 11:29:36 CET 2014 i686 GNU/Linux
>
> Gnu C 4.4.3
> Gnu make 3.81
> binutils 2.20.1
> util-linux 2.17.2
> mount support
> module-init-tools found
> e2fsprogs 1.42.11
> PPP 2.4.5
> Linux C Library 2.11.1
> Dynamic linker (ldd) 2.11.1
> Procps 3.2.8
> Net-tools 1.60
> Kbd 1.15
> Sh-utils found
> Modules Loaded xt_TPROXY xt_set xt_socket nf_defrag_ipv6 xt_REDIRECT ip_set_hash_ip hwmon_vid hwmon bridge ip_set iptable_nat nf_nat_ipv4 ipt_REJECT nf_nat_irc nf_conntrack_irc nf_nat_ftp nf_nat nf_conntrack_ftp msr ipmi_devintf ipmi_msghandler ip_gre gre bonding pcspkr shpchp uhci_hcd ehci_pci ehci_hcd lpc_ich mfd_core pata_acpi ata_generic
>
> If you have any questions or need more information or tests, I will gladly help you with that.
>
> Thank you in advance.
>
> Best regards,
> Peter Schmitt
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [net-next 05/13] i40e: add range check to i40e_aq_rc_to_posix
From: Sergei Shtylyov @ 2014-12-09 14:23 UTC (permalink / raw)
To: Jeff Kirsher, davem; +Cc: Shannon Nelson, netdev, nhorman, sassmann, jogreene
In-Reply-To: <1418124170-7495-6-git-send-email-jeffrey.t.kirsher@intel.com>
Hello.
On 12/9/2014 2:22 PM, Jeff Kirsher wrote:
> From: Shannon Nelson <shannon.nelson@intel.com>
> Just to be sure, add a range check to avoid any possible
> array index-out-of-bound issues.
> Change-ID: I9323bee6732c2a47599816e1d6c6b3a1f8dcbf54
> Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
> Acked-by: Michal Kosiarz <michal.kosiarz@intel.com>
> Tested-by: Jim Young <jamesx.m.young@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
> drivers/net/ethernet/intel/i40e/i40e_adminq.h | 2 ++
> drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 2 ++
> 2 files changed, 4 insertions(+)
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> index 618fe96..4064b1e 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
> -EFBIG, /* I40E_AQ_RC_EFBIG */
> };
>
> + if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
There's ARRAY_SIZE() macro exactly for such computations. And parens
around the last 'aq_to_posix' are not needed.
> + return -ERANGE;
> return aq_to_posix[aq_rc];
> }
>
> diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> index d5d3c93..4d63514 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
> -EFBIG, /* I40E_AQ_RC_EFBIG */
> };
>
> + if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
Likewise.
[...]
WBR, Sergei
^ permalink raw reply
* Re: Where exactly will arch_fast_hash be used
From: Herbert Xu @ 2014-12-09 14:24 UTC (permalink / raw)
To: George Spelvin
Cc: davem, dborkman, hannes, linux-kernel, netdev, tgraf, tytso
In-Reply-To: <20141207132305.24691.qmail@ns.horizon.com>
On Sun, Dec 07, 2014 at 08:23:05AM -0500, George Spelvin wrote:
>
> Okay, I'm confused. *What* scheme? The arch_fast_hash interface doesn't
> have any provision for a secret. Because there's no point to having one;
It does actually, in the form of the seed parameter. That's why
it's so bad: it pretends to be a semi-secure hash function that
people will use in hash tables.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* Re: [bisected] xfrm: TCP connection initiating PMTU discovery stalls on v3.
From: Eric Dumazet @ 2014-12-09 14:26 UTC (permalink / raw)
To: Thomas Jarosch
Cc: Wolfgang Walter, netdev, Eric Dumazet, Herbert Xu,
Steffen Klassert
In-Reply-To: <3594382.qsqLZcX7yO@storm>
On Tue, 2014-12-09 at 09:54 +0100, Thomas Jarosch wrote:
> On Monday, 8. December 2014 23:20:42 Wolfgang Walter wrote:
> > Am Freitag, 5. Dezember 2014, 05:26:25 schrieb Eric Dumazet:
> > > On Fri, 2014-12-05 at 13:09 +0100, Wolfgang Walter wrote:
> > > > Hello,
> > > >
> > > > as reverting this patch fixes this rather annoying problem: is it
> > > > dangerous to revert it as a workaround until the root cause is found?
> > >
> > > Unfortunately no, this patch fixes a serious issue.
> > >
> > > We need to find the root cause of your problem instead of trying to work
> > > around it.
> >
> > I only wanted to use it as local workaround here.
> >
> >
> > I looked a bit at at code. I'm not familiar with the network code, though
> > :-).
>
> If it helps, I'm running the reverted patch on five production boxes hitherto
> without a hiccup. As far as I understood the original commit message,
> some packet counters might me wrong without it.
>
> @Eric: What could possibly go wrong(tm)? :)
Crashes in TCP stack, because of packet count mismatches.
The sk_can_gso() status is already tested in tcp_sendmsg() as a hint,
since path behavior can dynamically be changed on existing flow :
<start a TCP flow>
ethtool -K eth0 tso off gso off
In this case, core networking stack detects this and segments the
packets _after_ TCP or IP stack, before they reach eth0.
TCP stack does not have to know that something is changed right before
giving a GSO packet to core networking stack, this would be racy by
nature, as TCP does not know or control full path. Hopefully we do not
take RTNL for every packet we send in TCP !
It seems XFRM triggers in a slow path something which is not correctly
handled.
It is not correct to add a racy kludge in TCP fast path for this very
unlikely case.
I would disable TSO/GSO on xfrm, and problem should disappear.
^ permalink raw reply
* [PATCH net] Fix race condition between vxlan_sock_add and vxlan_sock_release
From: Marcelo Ricardo Leitner @ 2014-12-09 14:28 UTC (permalink / raw)
To: netdev
Currently, when trying to reuse a socket, vxlan_sock_add will grab
vn->sock_lock, locate a reusable socket, inc refcount and release
vn->sock_lock.
But vxlan_sock_release() will first decrement refcount, and then grab
that lock. refcnt operations are atomic but as currently we have
deferred works which hold vs->refcnt each, this might happen, leading to
a use after free (specially after vxlan_igmp_leave):
CPU 1 CPU 2
deferred work vxlan_sock_add
... ...
spin_lock(&vn->sock_lock)
vs = vxlan_find_sock();
vxlan_sock_release
dec vs->refcnt, reaches 0
spin_lock(&vn->sock_lock)
vxlan_sock_hold(vs), refcnt=1
spin_unlock(&vn->sock_lock)
hlist_del_rcu(&vs->hlist);
vxlan_notify_del_rx_port(vs)
spin_unlock(&vn->sock_lock)
With current logic, as vxlan_sock_add is the only "search and hold",
it's easier to fix this by just making vxlan_sock_release grab that lock
before checking refcnt.
Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
---
drivers/net/vxlan.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 31ecb03368c6dc3d581fdbd30b409b88190f3c71..287e718c8a419394fb17b9a8eb5957aafb8d19da 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1057,10 +1057,15 @@ void vxlan_sock_release(struct vxlan_sock *vs)
struct net *net = sock_net(sk);
struct vxlan_net *vn = net_generic(net, vxlan_net_id);
- if (!atomic_dec_and_test(&vs->refcnt))
+ /* We have to take this lock now, otherwise vxlan_sock_add may
+ * reuse a socket that vxlan_igmp_leave just freed.
+ */
+ spin_lock(&vn->sock_lock);
+ if (!atomic_dec_and_test(&vs->refcnt)) {
+ spin_unlock(&vn->sock_lock);
return;
+ }
- spin_lock(&vn->sock_lock);
hlist_del_rcu(&vs->hlist);
vxlan_notify_del_rx_port(vs);
spin_unlock(&vn->sock_lock);
@@ -1987,7 +1992,7 @@ static int vxlan_init(struct net_device *dev)
vxlan->dst_port);
if (vs) {
/* If we have a socket with same port already, reuse it */
- atomic_inc(&vs->refcnt);
+ vxlan_sock_hold(vs);
vxlan_vs_add_dev(vs, vxlan);
} else {
/* otherwise make new socket outside of RTNL */
@@ -2391,7 +2396,7 @@ struct vxlan_sock *vxlan_sock_add(struct net *net, __be16 port,
vs = vxlan_find_sock(net, ipv6 ? AF_INET6 : AF_INET, port);
if (vs) {
if (vs->rcv == rcv)
- atomic_inc(&vs->refcnt);
+ vxlan_sock_hold(vs);
else
vs = ERR_PTR(-EBUSY);
}
--
1.9.3
^ permalink raw reply related
* [PATCH net] gianfar: Fix dma check map error when DMA_API_DEBUG is enabled
From: Claudiu Manoil @ 2014-12-09 14:24 UTC (permalink / raw)
To: netdev; +Cc: David S. Miller, Kevin Hao
In-Reply-To: <1417775874-17775-1-git-send-email-asolokha@kb.kras.ru>
From: Kevin Hao <haokexin@gmail.com>
We need to use dma_mapping_error() to check the dma address returned
by dma_map_single/page(). Otherwise we would get warning like this:
WARNING: at lib/dma-debug.c:1140
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.18.0-rc2-next-20141029 #196
task: c0834300 ti: effe6000 task.ti: c0874000
NIP: c02b2c98 LR: c02b2c98 CTR: c030abc4
REGS: effe7d70 TRAP: 0700 Not tainted (3.18.0-rc2-next-20141029)
MSR: 00021000 <CE,ME> CR: 22044022 XER: 20000000
GPR00: c02b2c98 effe7e20 c0834300 00000098 00021000 00000000 c030b898 00000003
GPR08: 00000001 00000000 00000001 749eec9d 22044022 1001abe0 00000020 ef278678
GPR16: ef278670 ef278668 ef278660 070a8040 c087f99c c08cdc60 00029000 c0840d44
GPR24: c08be6e8 c0840000 effe7e78 ef041340 00000600 ef114e10 00000000 c08be6e0
NIP [c02b2c98] check_unmap+0x51c/0x9e4
LR [c02b2c98] check_unmap+0x51c/0x9e4
Call Trace:
[effe7e20] [c02b2c98] check_unmap+0x51c/0x9e4 (unreliable)
[effe7e70] [c02b31d8] debug_dma_unmap_page+0x78/0x8c
[effe7ed0] [c03d1640] gfar_clean_rx_ring+0x208/0x488
[effe7f40] [c03d1a9c] gfar_poll_rx_sq+0x3c/0xa8
[effe7f60] [c04f8714] net_rx_action+0xc0/0x178
[effe7f90] [c00435a0] __do_softirq+0x100/0x1fc
[effe7fe0] [c0043958] irq_exit+0xa4/0xc8
[effe7ff0] [c000d14c] call_do_irq+0x24/0x3c
[c0875e90] [c00048a0] do_IRQ+0x8c/0xf8
[c0875eb0] [c000ed10] ret_from_except+0x0/0x18
For TX, we need to unmap the pages which has already been mapped and
free the skb before return. For RX, just let the rxbdp as unempty.
We can retry to initialize it to empty in next round.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
---
drivers/net/ethernet/freescale/gianfar.c | 58 ++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 4fdf0aa..0253402 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -117,8 +117,8 @@ static void gfar_reset_task(struct work_struct *work);
static void gfar_timeout(struct net_device *dev);
static int gfar_close(struct net_device *dev);
struct sk_buff *gfar_new_skb(struct net_device *dev);
-static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
- struct sk_buff *skb);
+static int gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
+ struct sk_buff *skb);
static int gfar_set_mac_address(struct net_device *dev);
static int gfar_change_mtu(struct net_device *dev, int new_mtu);
static irqreturn_t gfar_error(int irq, void *dev_id);
@@ -219,9 +219,13 @@ static int gfar_init_bds(struct net_device *ndev)
netdev_err(ndev, "Can't allocate RX buffers\n");
return -ENOMEM;
}
- rx_queue->rx_skbuff[j] = skb;
- gfar_new_rxbdp(rx_queue, rxbdp, skb);
+ if (gfar_new_rxbdp(rx_queue, rxbdp, skb)) {
+ dev_kfree_skb_any(skb);
+ skb = NULL;
+ }
+
+ rx_queue->rx_skbuff[j] = skb;
}
rxbdp++;
@@ -2290,6 +2294,8 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
0,
frag_len,
DMA_TO_DEVICE);
+ if (unlikely(dma_mapping_error(priv->dev, bufaddr)))
+ goto dma_map_err;
/* set the TxBD length and buffer pointer */
txbdp->bufPtr = bufaddr;
@@ -2339,8 +2345,12 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
fcb->ptp = 1;
}
- txbdp_start->bufPtr = dma_map_single(priv->dev, skb->data,
- skb_headlen(skb), DMA_TO_DEVICE);
+ bufaddr = dma_map_single(priv->dev, skb->data, skb_headlen(skb),
+ DMA_TO_DEVICE);
+ if (unlikely(dma_mapping_error(priv->dev, bufaddr)))
+ goto dma_map_err;
+
+ txbdp_start->bufPtr = bufaddr;
/* If time stamping is requested one additional TxBD must be set up. The
* first TxBD points to the FCB and must have a data length of
@@ -2406,6 +2416,25 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
spin_unlock_irqrestore(&tx_queue->txlock, flags);
return NETDEV_TX_OK;
+
+dma_map_err:
+ txbdp = next_txbd(txbdp_start, base, tx_queue->tx_ring_size);
+ if (do_tstamp)
+ txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
+ for (i = 0; i < nr_frags; i++) {
+ lstatus = txbdp->lstatus;
+ if (!(lstatus & BD_LFLAG(TXBD_READY)))
+ break;
+
+ txbdp->lstatus = lstatus & ~BD_LFLAG(TXBD_READY);
+ bufaddr = txbdp->bufPtr;
+ dma_unmap_page(priv->dev, bufaddr, txbdp->length,
+ DMA_TO_DEVICE);
+ txbdp = next_txbd(txbdp, base, tx_queue->tx_ring_size);
+ }
+ gfar_wmb();
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
}
/* Stops the kernel queue, and halts the controller */
@@ -2606,8 +2635,8 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
netdev_tx_completed_queue(txq, howmany, bytes_sent);
}
-static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
- struct sk_buff *skb)
+static int gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
+ struct sk_buff *skb)
{
struct net_device *dev = rx_queue->dev;
struct gfar_private *priv = netdev_priv(dev);
@@ -2615,7 +2644,11 @@ static void gfar_new_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
buf = dma_map_single(priv->dev, skb->data,
priv->rx_buffer_size, DMA_FROM_DEVICE);
+ if (unlikely(dma_mapping_error(priv->dev, buf)))
+ return -1;
+
gfar_init_rxbdp(rx_queue, bdp, buf);
+ return 0;
}
static struct sk_buff *gfar_alloc_skb(struct net_device *dev)
@@ -2851,10 +2884,13 @@ int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, int rx_work_limit)
}
- rx_queue->rx_skbuff[rx_queue->skb_currx] = newskb;
-
/* Setup the new bdp */
- gfar_new_rxbdp(rx_queue, bdp, newskb);
+ if (unlikely(gfar_new_rxbdp(rx_queue, bdp, newskb))) {
+ dev_kfree_skb_any(newskb);
+ newskb = NULL;
+ }
+
+ rx_queue->rx_skbuff[rx_queue->skb_currx] = newskb;
/* Update to the next pointer */
bdp = next_bd(bdp, base, rx_queue->rx_ring_size);
--
1.7.11.7
^ permalink raw reply related
* [RFC PATCH net-next 00/11] net: remove disable_irq() from ->ndo_poll_controller
From: Sabrina Dubroca @ 2014-12-09 14:37 UTC (permalink / raw)
To: davem; +Cc: netdev, Sabrina Dubroca, Peter Zijlstra, Thomas Gleixner
In commit e22b886a8a43b ("sched/wait: Add might_sleep() checks"),
Peter Zijlstra added a check that fires on netpoll controllers that
use disable_irq().
There are 60 drivers currently using disable_irq() in their netpoll
controller. A lot of these simply disable irqs before calling their
interrupt handler. A few do something a little more complex, often
with multiple irqs.
Thomas Gleixner and Peter Zijlstra suggested the idea of a adding a
spinlock in the interrupt handler and submitted the initial patch for
this: https://lkml.org/lkml/2014/10/29/742
There are three groups of drivers/netpoll controllers that need to be
fixed:
1) drivers that simply disable_irq()
a) interrupt handler takes a lock
examples: 8139cp/8139too
The disable_irq() call is not necessary, we can just remove it
and rely on the lock in the interrupt handler.
b) interrupt handler doesn't take a lock
examples: e1000, atl1c
Add locking to the interrupt handler, remove the disable_irq() call.
2) other drivers
These are the other drivers whose netpoll controller use disable_irq:
drivers/net/ethernet/nvidia/forcedeth.c
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/neterion/s2io.c
drivers/net/ethernet/neterion/vxge/vxge-main.c
drivers/net/ethernet/silan/sc92031.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/pasemi/pasemi_mac.c
drivers/net/ethernet/xilinx/ll_temac_main.c
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
Additionally, igb calls synchronize_irq()
in igb_netpoll -> igb_irq_disable.
These patches provide new helpers to lock the interrupt handler
against netpoll controller, and convert a few drivers as examples for
each group. I will take care of the rest if this RFC passes the
review.
e1000 and 8139cp have been tested on QEMU, the rest has only been
compiled. The changes to drivers in group 2) are more complex, and
need more careful review.
Note: I'm not sure whether this should go into net-next or net. For
now, since the check was only in linux-next, I based the patches on
net-next. But Peter and Thomas said:
>> But I suspect most all the network drivers will need this and maybe
>> more, disable_irq() is a popular little thing and we 'just' changed
>> semantics on them.
>
> We changed that almost 4 years ago :) What we 'just' did was to add
> a prominent warning into the code.
Please review and comment. Thanks!
Sabrina Dubroca (11):
netpoll: introduce netpoll_irq_lock to protect netpoll controller
against interrupts
e1000: remove disable_irq from netpoll controller, use
netpoll_irq_lock
8139cp/too: remove disable_irq from netpoll controller
atl1c: remove disable_irq from netpoll controller, use
netpoll_irq_lock
bnx2: remove disable_irq from netpoll controller, use netpoll_irq_lock
s2io: remove disable_irq from netpoll controller, use netpoll_irq_lock
pasemi: remove disable_irq from netpoll controller, use
netpoll_irq_lock
ll_temac: remove disable_irq from netpoll controller, use
netpoll_irq_lock
xilinx/axienet: remove disable_irq from netpoll controller, use
netpoll_irq_lock
gianfar: remove disable_irq from netpoll controller, use
netpoll_irq_lock
net: fec: remove disable_irq from netpoll controller, use
netpoll_irq_lock
drivers/net/ethernet/atheros/atl1c/atl1c.h | 3 ++
drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 12 ++++---
drivers/net/ethernet/broadcom/bnx2.c | 24 ++++++++++----
drivers/net/ethernet/broadcom/bnx2.h | 4 +++
drivers/net/ethernet/freescale/fec.h | 2 ++
drivers/net/ethernet/freescale/fec_main.c | 14 +++++++++
drivers/net/ethernet/freescale/gianfar.c | 38 ++++++++++-------------
drivers/net/ethernet/freescale/gianfar.h | 5 +++
drivers/net/ethernet/intel/e1000/e1000.h | 3 ++
drivers/net/ethernet/intel/e1000/e1000_main.c | 21 ++++++++++---
drivers/net/ethernet/neterion/s2io.c | 27 +++++++++-------
drivers/net/ethernet/neterion/s2io.h | 4 +++
drivers/net/ethernet/pasemi/pasemi_mac.c | 25 +++++++++------
drivers/net/ethernet/pasemi/pasemi_mac.h | 3 ++
drivers/net/ethernet/realtek/8139cp.c | 3 +-
drivers/net/ethernet/realtek/8139too.c | 3 +-
drivers/net/ethernet/xilinx/ll_temac.h | 3 ++
drivers/net/ethernet/xilinx/ll_temac_main.c | 13 ++++----
drivers/net/ethernet/xilinx/xilinx_axienet.h | 3 ++
drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 15 +++++----
include/linux/netpoll.h | 31 ++++++++++++++++++
21 files changed, 182 insertions(+), 74 deletions(-)
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
--
2.1.3
^ permalink raw reply
* [RFC PATCH net-next 01/11] netpoll: introduce netpoll_irq_lock to protect netpoll controller against interrupts
From: Sabrina Dubroca @ 2014-12-09 14:37 UTC (permalink / raw)
To: davem; +Cc: netdev, Sabrina Dubroca, Peter Zijlstra, Thomas Gleixner
In-Reply-To: <1418135842-21389-1-git-send-email-sd@queasysnail.net>
In many drivers' ->ndo_poll_controller implementation, we currently
have the following code:
static void poll_controller(struct net_device *dev)
{
disable_irq(irq);
intr_handler(irq, dev);
enable_irq(irq);
}
Commit e22b886a8a43b ("sched/wait: Add might_sleep() checks") added a
might_sleep() check to synchronize_irq(). Thomas Gleixner and Peter
Zijlstra suggested the original idea and patch to replace disable_irq
in the poll controller with a spin_lock in the interrupt handler.
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/netpoll.h | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index b25ee9ffdbe6..a171f1a50e0e 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -117,4 +117,35 @@ static inline bool netpoll_tx_running(struct net_device *dev)
}
#endif
+struct netpoll_irq_lock {
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ spinlock_t lock;
+#endif
+};
+
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static inline void netpoll_irq_lock_init(struct netpoll_irq_lock *np_lock)
+{
+ spin_lock_init(&np_lock->lock);
+}
+static inline void netpoll_irq_lock(struct netpoll_irq_lock *np_lock)
+{
+ spin_lock(&np_lock->lock);
+}
+static inline void netpoll_irq_unlock(struct netpoll_irq_lock *np_lock)
+{
+ spin_unlock(&np_lock->lock);
+}
+#else
+static inline void netpoll_irq_lock_init(struct netpoll_irq_lock *np_lock)
+{
+}
+static inline void netpoll_irq_lock(struct netpoll_irq_lock *np_lock)
+{
+}
+static inline void netpoll_irq_unlock(struct netpoll_irq_lock *np_lock)
+{
+}
+#endif
+
#endif
--
2.1.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox