diff mbox series

[V1,net-next,10/10] net: ena: Extract recurring driver reset code into a function

Message ID 20220106192915.22616-11-akiyano@amazon.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series ENA: capabilities field and cosmetic | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 0 this patch: 24
netdev/cc_maintainers warning 1 maintainers not CCed: sameehj@amazon.com
netdev/build_clang fail Errors and warnings before: 2 this patch: 16
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 24
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns WARNING: line length of 95 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kiyanovski, Arthur Jan. 6, 2022, 7:29 p.m. UTC
Create an inline function for resetting the driver
to reduce code duplication.

Signed-off-by: Nati Koler <nkoler@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
---
 drivers/net/ethernet/amazon/ena/ena_netdev.c | 45 ++++++--------------
 drivers/net/ethernet/amazon/ena/ena_netdev.h |  8 ++++
 2 files changed, 22 insertions(+), 31 deletions(-)

Comments

Jakub Kicinski Jan. 7, 2022, 3 a.m. UTC | #1
On Thu, 6 Jan 2022 19:29:15 +0000 Arthur Kiyanovski wrote:
> Create an inline function for resetting the driver
> to reduce code duplication.

> +static inline void ena_reset_device(struct ena_adapter *adapter, enum ena_flags_t reset_reason)

Looks like you picked the wrong type because new W=1 warnings abound:

In file included from ../drivers/net/ethernet/amazon/ena/ena_netdev.c:21:
../drivers/net/ethernet/amazon/ena/ena_netdev.h: In function ‘ena_reset_device’:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit conversion from ‘enum ena_flags_t’ to ‘enum ena_regs_reset_reason_types’ [-Wenum-conversion]
  399 |         adapter->reset_reason = reset_reason;
      |                               ^
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘ena_tx_timeout’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:106:35: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
  106 |         ena_reset_device(adapter, ENA_REGS_RESET_OS_NETDEV_WD);
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘ena_xmit_common’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:171:42: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
  171 |                                          ENA_REGS_RESET_DRIVER_INVALID_STATE);
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘handle_invalid_req_id’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:1280:41: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 1280 |         ena_reset_device(ring->adapter, ENA_REGS_RESET_INV_TX_REQ_ID);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘ena_rx_skb’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:1444:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 1444 |                 ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘ena_clean_rx_irq’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:1777:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 1777 |                 ena_reset_device(adapter, ENA_REGS_RESET_TOO_MANY_RX_DESCS);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c:1781:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 1781 |                 ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘check_for_rx_interrupt_queue’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:3701:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 3701 |                 ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘check_missing_comp_in_tx_queue’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:3738:51: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 3738 |                         ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c:3764:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 3764 |                 ena_reset_device(adapter, ENA_REGS_RESET_MISS_TX_CMPL);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘check_for_missing_keep_alive’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:3885:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 3885 |                 ena_reset_device(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function ‘check_for_admin_com_state’:
../drivers/net/ethernet/amazon/ena/ena_netdev.c:3896:43: warning: implicit conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum ena_flags_t’ [-Wenum-conversion]
 3896 |                 ena_reset_device(adapter, ENA_REGS_RESET_ADMIN_TO);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/net/ethernet/amazon/ena/ena_ethtool.c:9:
../drivers/net/ethernet/amazon/ena/ena_netdev.h: In function ‘ena_reset_device’:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit conversion from ‘enum ena_flags_t’ to ‘enum ena_regs_reset_reason_types’ [-Wenum-conversion]
  399 |         adapter->reset_reason = reset_reason;
      |                               ^
../drivers/net/ethernet/amazon/ena/ena_netdev.c: note: in included file:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing different enum types:
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_flags_t
../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int enum ena_regs_reset_reason_types


While you're fixing things it'd also be cool to address the existing
clang warning:

drivers/net/ethernet/amazon/ena/ena_netdev.c:1892:6: warning: variable 'tx_bytes' set but not used [-Wunused-but-set-variable]
        u32 tx_bytes = 0;
            ^
Kiyanovski, Arthur Jan. 7, 2022, 8:12 p.m. UTC | #2
>-----Original Message-----
>From: Jakub Kicinski <kuba@kernel.org>
>Sent: Friday, January 7, 2022 5:00 AM
>To: Kiyanovski, Arthur <akiyano@amazon.com>
>Cc: David Miller <davem@davemloft.net>; netdev@vger.kernel.org;
>Woodhouse, David <dwmw@amazon.co.uk>; Machulsky, Zorik
><zorik@amazon.com>; Matushevsky, Alexander <matua@amazon.com>;
>Bshara, Saeed <saeedb@amazon.com>; Wilson, Matt <msw@amazon.com>;
>Liguori, Anthony <aliguori@amazon.com>; Bshara, Nafea
><nafea@amazon.com>; Belgazal, Netanel <netanel@amazon.com>; Saidi, Ali
><alisaidi@amazon.com>; Herrenschmidt, Benjamin <benh@amazon.com>;
>Dagan, Noam <ndagan@amazon.com>; Agroskin, Shay
><shayagr@amazon.com>; Arinzon, David <darinzon@amazon.com>; Koler,
>Nethanel <nkoler@amazon.com>
>Subject: RE: [EXTERNAL] [PATCH V1 net-next 10/10] net: ena: Extract recurring
>driver reset code into a function
>
>CAUTION: This email originated from outside of the organization. Do not click
>links or open attachments unless you can confirm the sender and know the
>content is safe.
>
>
>
>On Thu, 6 Jan 2022 19:29:15 +0000 Arthur Kiyanovski wrote:
>> Create an inline function for resetting the driver to reduce code
>> duplication.
>
>> +static inline void ena_reset_device(struct ena_adapter *adapter, enum
>> +ena_flags_t reset_reason)
>
>Looks like you picked the wrong type because new W=1 warnings abound:
>
>In file included from ../drivers/net/ethernet/amazon/ena/ena_netdev.c:21:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h: In function
>‘ena_reset_device’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit
>conversion from ‘enum ena_flags_t’ to ‘enum
>ena_regs_reset_reason_types’ [-Wenum-conversion]
>  399 |         adapter->reset_reason = reset_reason;
>      |                               ^
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘ena_tx_timeout’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:106:35: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
>  106 |         ena_reset_device(adapter, ENA_REGS_RESET_OS_NETDEV_WD);
>      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘ena_xmit_common’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:171:42: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
>  171 |                                          ENA_REGS_RESET_DRIVER_INVALID_STATE);
>      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘handle_invalid_req_id’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:1280:41: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 1280 |         ena_reset_device(ring->adapter,
>ENA_REGS_RESET_INV_TX_REQ_ID);
>      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘ena_rx_skb’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:1444:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 1444 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_INV_RX_REQ_ID);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘ena_clean_rx_irq’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:1777:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 1777 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_TOO_MANY_RX_DESCS);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:1781:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 1781 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_INV_RX_REQ_ID);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘check_for_rx_interrupt_queue’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:3701:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 3701 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_MISS_INTERRUPT);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘check_missing_comp_in_tx_queue’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:3738:51: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 3738 |                         ena_reset_device(adapter,
>ENA_REGS_RESET_MISS_INTERRUPT);
>      |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:3764:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 3764 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_MISS_TX_CMPL);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘check_for_missing_keep_alive’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:3885:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 3885 |                 ena_reset_device(adapter,
>ENA_REGS_RESET_KEEP_ALIVE_TO);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: In function
>‘check_for_admin_com_state’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.c:3896:43: warning: implicit
>conversion from ‘enum ena_regs_reset_reason_types’ to ‘enum
>ena_flags_t’ [-Wenum-conversion]
> 3896 |                 ena_reset_device(adapter, ENA_REGS_RESET_ADMIN_TO);
>      |                                           ^~~~~~~~~~~~~~~~~~~~~~~
>In file included from ../drivers/net/ethernet/amazon/ena/ena_ethtool.c:9:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h: In function
>‘ena_reset_device’:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit
>conversion from ‘enum ena_flags_t’ to ‘enum
>ena_regs_reset_reason_types’ [-Wenum-conversion]
>  399 |         adapter->reset_reason = reset_reason;
>      |                               ^
>../drivers/net/ethernet/amazon/ena/ena_netdev.c: note: in included file:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33: warning: mixing
>different enum types:
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_flags_t
>../drivers/net/ethernet/amazon/ena/ena_netdev.h:399:33:    unsigned int
>enum ena_regs_reset_reason_types
>
>
>While you're fixing things it'd also be cool to address the existing clang
>warning:
>
>drivers/net/ethernet/amazon/ena/ena_netdev.c:1892:6: warning: variable
>'tx_bytes' set but not used [-Wunused-but-set-variable]
>        u32 tx_bytes = 0;
>            ^

Sorry about that, v2 of this patchset will fix the "mixing different enum types" warning
Will address the clang warning in the next patchset.
Jakub Kicinski Jan. 7, 2022, 8:21 p.m. UTC | #3
On Fri, 7 Jan 2022 20:12:26 +0000 Kiyanovski, Arthur wrote:
> Sorry about that, v2 of this patchset will fix the "mixing different enum types" warning
> Will address the clang warning in the next patchset.

Sgtm, thanks!
kernel test robot Jan. 8, 2022, 10:33 a.m. UTC | #4
Hi Arthur,

I love your patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Arthur-Kiyanovski/ENA-capabilities-field-and-cosmetic/20220107-034036
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 710ad98c363a66a0cd8526465426c5c5f8377ee0
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20220108/202201081810.cbanKMEo-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/fc12048d64c67fe13a46a2a3932df606c29ac4d9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arthur-Kiyanovski/ENA-capabilities-field-and-cosmetic/20220107-034036
        git checkout fc12048d64c67fe13a46a2a3932df606c29ac4d9
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=alpha SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/amazon/ena/ena_netdev.c:21:
   drivers/net/ethernet/amazon/ena/ena_netdev.h: In function 'ena_reset_device':
>> drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit conversion from 'enum ena_flags_t' to 'enum ena_regs_reset_reason_types' [-Wenum-conversion]
     399 |         adapter->reset_reason = reset_reason;
         |                               ^
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_tx_timeout':
>> drivers/net/ethernet/amazon/ena/ena_netdev.c:106:35: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
     106 |         ena_reset_device(adapter, ENA_REGS_RESET_OS_NETDEV_WD);
         |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_xmit_common':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:171:42: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
     171 |                                          ENA_REGS_RESET_DRIVER_INVALID_STATE);
         |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'handle_invalid_req_id':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:1280:41: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    1280 |         ena_reset_device(ring->adapter, ENA_REGS_RESET_INV_TX_REQ_ID);
         |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_rx_skb':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:1444:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    1444 |                 ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'ena_clean_rx_irq':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:1777:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    1777 |                 ena_reset_device(adapter, ENA_REGS_RESET_TOO_MANY_RX_DESCS);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c:1781:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    1781 |                 ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'check_for_rx_interrupt_queue':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:3701:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    3701 |                 ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'check_missing_comp_in_tx_queue':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:3738:51: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    3738 |                         ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
         |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c:3764:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    3764 |                 ena_reset_device(adapter, ENA_REGS_RESET_MISS_TX_CMPL);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'check_for_missing_keep_alive':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:3885:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    3885 |                 ena_reset_device(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/amazon/ena/ena_netdev.c: In function 'check_for_admin_com_state':
   drivers/net/ethernet/amazon/ena/ena_netdev.c:3896:43: warning: implicit conversion from 'enum ena_regs_reset_reason_types' to 'enum ena_flags_t' [-Wenum-conversion]
    3896 |                 ena_reset_device(adapter, ENA_REGS_RESET_ADMIN_TO);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~
--
   In file included from drivers/net/ethernet/amazon/ena/ena_ethtool.c:9:
   drivers/net/ethernet/amazon/ena/ena_netdev.h: In function 'ena_reset_device':
>> drivers/net/ethernet/amazon/ena/ena_netdev.h:399:31: warning: implicit conversion from 'enum ena_flags_t' to 'enum ena_regs_reset_reason_types' [-Wenum-conversion]
     399 |         adapter->reset_reason = reset_reason;
         |                               ^


vim +399 drivers/net/ethernet/amazon/ena/ena_netdev.h

   396	
   397	static inline void ena_reset_device(struct ena_adapter *adapter, enum ena_flags_t reset_reason)
   398	{
 > 399		adapter->reset_reason = reset_reason;
   400		/* Make sure reset reason is set before triggering the reset */
   401		smp_mb__before_atomic();
   402		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
   403	}
   404	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index 0cc72303a2da..53080fd143dc 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -103,7 +103,7 @@  static void ena_tx_timeout(struct net_device *dev, unsigned int txqueue)
 	if (test_and_set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))
 		return;
 
-	adapter->reset_reason = ENA_REGS_RESET_OS_NETDEV_WD;
+	ena_reset_device(adapter, ENA_REGS_RESET_OS_NETDEV_WD);
 	ena_increase_stat(&adapter->dev_stats.tx_timeout, 1, &adapter->syncp);
 
 	netif_err(adapter, tx_err, dev, "Transmit time out\n");
@@ -166,11 +166,9 @@  static int ena_xmit_common(struct net_device *dev,
 			  "Failed to prepare tx bufs\n");
 		ena_increase_stat(&ring->tx_stats.prepare_ctx_err, 1,
 				  &ring->syncp);
-		if (rc != -ENOMEM) {
-			adapter->reset_reason =
-				ENA_REGS_RESET_DRIVER_INVALID_STATE;
-			set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
-		}
+		if (rc != -ENOMEM)
+			ena_reset_device(adapter,
+					 ENA_REGS_RESET_DRIVER_INVALID_STATE);
 		return rc;
 	}
 
@@ -1279,10 +1277,8 @@  static int handle_invalid_req_id(struct ena_ring *ring, u16 req_id,
 			  req_id, ring->qid);
 
 	ena_increase_stat(&ring->tx_stats.bad_req_id, 1, &ring->syncp);
+	ena_reset_device(ring->adapter, ENA_REGS_RESET_INV_TX_REQ_ID);
 
-	/* Trigger device reset */
-	ring->adapter->reset_reason = ENA_REGS_RESET_INV_TX_REQ_ID;
-	set_bit(ENA_FLAG_TRIGGER_RESET, &ring->adapter->flags);
 	return -EFAULT;
 }
 
@@ -1445,10 +1441,7 @@  static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
 		netif_err(adapter, rx_err, rx_ring->netdev,
 			  "Page is NULL. qid %u req_id %u\n", rx_ring->qid, req_id);
 		ena_increase_stat(&rx_ring->rx_stats.bad_req_id, 1, &rx_ring->syncp);
-		adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID;
-		/* Make sure reset reason is set before triggering the reset */
-		smp_mb__before_atomic();
-		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+		ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
 		return NULL;
 	}
 
@@ -1781,15 +1774,12 @@  static int ena_clean_rx_irq(struct ena_ring *rx_ring, struct napi_struct *napi,
 	if (rc == -ENOSPC) {
 		ena_increase_stat(&rx_ring->rx_stats.bad_desc_num, 1,
 				  &rx_ring->syncp);
-		adapter->reset_reason = ENA_REGS_RESET_TOO_MANY_RX_DESCS;
+		ena_reset_device(adapter, ENA_REGS_RESET_TOO_MANY_RX_DESCS);
 	} else {
 		ena_increase_stat(&rx_ring->rx_stats.bad_req_id, 1,
 				  &rx_ring->syncp);
-		adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID;
+		ena_reset_device(adapter, ENA_REGS_RESET_INV_RX_REQ_ID);
 	}
-
-	set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
-
 	return 0;
 }
 
@@ -3707,9 +3697,8 @@  static int check_for_rx_interrupt_queue(struct ena_adapter *adapter,
 		netif_err(adapter, rx_err, adapter->netdev,
 			  "Potential MSIX issue on Rx side Queue = %d. Reset the device\n",
 			  rx_ring->qid);
-		adapter->reset_reason = ENA_REGS_RESET_MISS_INTERRUPT;
-		smp_mb__before_atomic();
-		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+
+		ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
 		return -EIO;
 	}
 
@@ -3746,9 +3735,7 @@  static int check_missing_comp_in_tx_queue(struct ena_adapter *adapter,
 			netif_err(adapter, tx_err, adapter->netdev,
 				  "Potential MSIX issue on Tx side Queue = %d. Reset the device\n",
 				  tx_ring->qid);
-			adapter->reset_reason = ENA_REGS_RESET_MISS_INTERRUPT;
-			smp_mb__before_atomic();
-			set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+			ena_reset_device(adapter, ENA_REGS_RESET_MISS_INTERRUPT);
 			return -EIO;
 		}
 
@@ -3774,9 +3761,7 @@  static int check_missing_comp_in_tx_queue(struct ena_adapter *adapter,
 			  "The number of lost tx completions is above the threshold (%d > %d). Reset the device\n",
 			  missed_tx,
 			  adapter->missing_tx_completion_threshold);
-		adapter->reset_reason =
-			ENA_REGS_RESET_MISS_TX_CMPL;
-		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+		ena_reset_device(adapter, ENA_REGS_RESET_MISS_TX_CMPL);
 		rc = -EIO;
 	}
 
@@ -3897,8 +3882,7 @@  static void check_for_missing_keep_alive(struct ena_adapter *adapter)
 			  "Keep alive watchdog timeout.\n");
 		ena_increase_stat(&adapter->dev_stats.wd_expired, 1,
 				  &adapter->syncp);
-		adapter->reset_reason = ENA_REGS_RESET_KEEP_ALIVE_TO;
-		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+		ena_reset_device(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO);
 	}
 }
 
@@ -3909,8 +3893,7 @@  static void check_for_admin_com_state(struct ena_adapter *adapter)
 			  "ENA admin queue is not in running state!\n");
 		ena_increase_stat(&adapter->dev_stats.admin_q_pause, 1,
 				  &adapter->syncp);
-		adapter->reset_reason = ENA_REGS_RESET_ADMIN_TO;
-		set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+		ena_reset_device(adapter, ENA_REGS_RESET_ADMIN_TO);
 	}
 }
 
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.h b/drivers/net/ethernet/amazon/ena/ena_netdev.h
index 1659f0b6b824..ee580f75454f 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.h
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.h
@@ -394,6 +394,14 @@  int ena_update_queue_count(struct ena_adapter *adapter, u32 new_channel_count);
 
 int ena_get_sset_count(struct net_device *netdev, int sset);
 
+static inline void ena_reset_device(struct ena_adapter *adapter, enum ena_flags_t reset_reason)
+{
+	adapter->reset_reason = reset_reason;
+	/* Make sure reset reason is set before triggering the reset */
+	smp_mb__before_atomic();
+	set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
+}
+
 enum ena_xdp_errors_t {
 	ENA_XDP_ALLOWED = 0,
 	ENA_XDP_CURRENT_MTU_TOO_LARGE,