iavf: stop leaking iavf_status as "errno" values
Subsystems (2)
PATCH v3 1/2 iavf: stop leaking iavf_status as "errno" values
Several functions in the iAVF core files take status values of the enum iavf_status and convert them into integer values. This leads to confusion as functions return both Linux errno values and status codes intermixed. Reporting status codes as if they were "errno" values can lead to confusion when reviewing error logs. Additionally, it can lead to unexpected behavior if a return value is not interpreted properly.
Fix this by introducing iavf_status_to_errno, a switch that explicitly converts from the status codes into an appropriate error value. Also introduce a virtchnl_status_to_errno function for the one case where we were returning both virtchnl status codes and iavf_status codes in the same function.
---
v2: Submit this with additional patch introducing iavf_status_to_errno function
v3: Change iavf_poll_virtchnl_msg to int
--- drivers/net/ethernet/intel/iavf/iavf.h | 5 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 172 +++++++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 18 +- 3 files changed, 156 insertions(+), 39 deletions(-)
drivers/net/ethernet/intel/iavf/iavf.h +4 -1
@@ -44,6 +44,9 @@#define DEFAULT_DEBUG_LEVEL_SHIFT 3#define PFX "iavf: " +int iavf_status_to_errno (enum iavf_status status); +int virtchnl_status_to_errno (enum virtchnl_status_code v_status); +/* VSI state flags shared with common code */ enum iavf_vsi_state_t { __IAVF_VSI_DOWN,
@@ -528,7 +531,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter);void iavf_del_vlans (struct iavf_adapter *adapter);void iavf_set_promiscuous (struct iavf_adapter *adapter,int flags);void iavf_request_stats (struct iavf_adapter *adapter); -void iavf_request_reset (struct iavf_adapter *adapter); +int iavf_request_reset (struct iavf_adapter *adapter);void iavf_get_hena (struct iavf_adapter *adapter);void iavf_set_hena (struct iavf_adapter *adapter);void iavf_set_rss_key (struct iavf_adapter *adapter);
drivers/net/ethernet/intel/iavf/iavf_main.c +142 -30
250 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +10 -8
@@ -22,17 +22,17 @@ static int iavf_send_pf_msg(struct iavf_adapter *adapter, enum virtchnl_ops op, u8 *msg, u16 len) { struct iavf_hw *hw = &adapter->hw; -enum iavf_status err; +enum iavf_status status;if (adapter->flags &IAVF_FLAG_PF_COMMS_FAILED )return 0 ;/* nothing to see here, move along */ - err =iavf_aq_send_msg_to_pf (hw, op,0 , msg, len,NULL ); -if (err) -dev_dbg (&adapter->pdev->dev,"Unable to send opcode %d to PF, err %s, aq_err %s\n" , - op,iavf_stat_str (hw, err), + status =iavf_aq_send_msg_to_pf (hw, op,0 , msg, len,NULL ); +if (status) +dev_dbg (&adapter->pdev->dev,"Unable to send opcode %d to PF, status %s, aq_err %s\n" , + op,iavf_stat_str (hw, status),iavf_aq_str (hw, hw->aq.asq_last_status)); -return err; +return iavf_status_to_errno (status); }/**
@@ -1848,11 +1848,13 @@ void iavf_del_adv_rss_cfg(struct iavf_adapter *adapter)* * Request that the PF reset this VF. No response is expected. **/ -void iavf_request_reset (struct iavf_adapter *adapter) +int iavf_request_reset (struct iavf_adapter *adapter) { +int err;/* Don't check CURRENT_OP - this is always higher priority */ -iavf_send_pf_msg (adapter,VIRTCHNL_OP_RESET_VF ,NULL ,0 ); + err =iavf_send_pf_msg (adapter,VIRTCHNL_OP_RESET_VF ,NULL ,0 ); adapter->current_op =VIRTCHNL_OP_UNKNOWN ; +return err; }/**
Signature · 1 line
2.27.0
Jankowski
PATCH v3 1/2 iavf: stop leaking iavf_status as "errno" values
drivers/net/ethernet/intel/iavf/iavf.h
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Mateusz Palczewski
Sent: Thursday, January 27, 2022 3:16 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Palczewski, Mateusz <[email protected]>
Subject: [Intel-wired-lan] [PATCH net-next v3 1/2] iavf: stop leakingiavf_statusas "errno" valuesSeveral functions in the iAVF core files take status values of the enum
iavf_statusand convert them into integer values. This leads to confusion as functions return both Linux errno values and status codes intermixed. Reporting status codes as if they were "errno" values can lead to confusion when reviewing error logs. Additionally, it can lead to unexpected behavior if a return value is not interpreted properly.Fix this by introducing
iavf_status_to_errno, a switch that explicitly converts from the status codes into an appropriate error value. Also introduce avirtchnl_status_to_errnofunction for the one case where we were returning both virtchnl status codes andiavf_statuscodes in the same function.Signed-off-by Jacob Keller <[email protected]>Signed-off-by Mateusz Palczewski <[email protected]>---
v2: Submit this with additional patch introducingiavf_status_to_errno
function
v3: Changeiavf_poll_virtchnl_msgto int--- drivers/net/ethernet/intel/iavf/iavf.h | 5 +- drivers/net/ethernet/intel/iavf/iavf_main.c | 172 +++++++++++++++--- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 18 +- 3 files changed, 156 insertions(+), 39 deletions(-)drivers/net/ethernet/intel/iavf/iavf.h +0
-0