[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240304210514.3412298-1-anthony.l.nguyen@intel.com>
Date: Mon, 4 Mar 2024 13:05:00 -0800
From: Tony Nguyen <anthony.l.nguyen@...el.com>
To: davem@...emloft.net,
kuba@...nel.org,
pabeni@...hat.com,
edumazet@...gle.com,
netdev@...r.kernel.org
Cc: Tony Nguyen <anthony.l.nguyen@...el.com>,
alan.brady@...el.com
Subject: [PATCH net-next 00/11][pull request] idpf: refactor virtchnl messages
Alan Brady says:
The motivation for this series has two primary goals. We want to enable
support of multiple simultaneous messages and make the channel more
robust. The way it works right now, the driver can only send and receive
a single message at a time and if something goes really wrong, it can
lead to data corruption and strange bugs.
To start the series, we introduce an idpf_virtchnl.h file. This reduces
the burden on idpf.h which is overloaded with struct and function
declarations.
The conversion works by conceptualizing a send and receive as a
"virtchnl transaction" (idpf_vc_xn) and introducing a "transaction
manager" (idpf_vc_xn_manager). The vcxn_mngr will init a ring of
transactions from which the driver will pop from a bitmap of free
transactions to track in-flight messages. Instead of needing to handle a
complicated send/recv for every a message, the driver now just needs to
fill out a xn_params struct and hand it over to idpf_vc_xn_exec which
will take care of all the messy bits. Once a message is sent and
receives a reply, we leverage the completion API to signal the received
buffer is ready to be used (assuming success, or an error code
otherwise).
At a low-level, this implements the "sw cookie" field of the virtchnl
message descriptor to enable this. We have 16 bits we can put whatever
we want and the recipient is required to apply the same cookie to the
reply for that message. We use the first 8 bits as an index into the
array of transactions to enable fast lookups and we use the second 8
bits as a salt to make sure each cookie is unique for that message. As
transactions are received in arbitrary order, it's possible to reuse a
transaction index and the salt guards against index conflicts to make
certain the lookup is correct. As a primitive example, say index 1 is
used with salt 1. The message times out without receiving a reply so
index 1 is renewed to be ready for a new transaction, we report the
timeout, and send the message again. Since index 1 is free to be used
again now, index 1 is again sent but now salt is 2. This time we do get
a reply, however it could be that the reply is _actually_ for the
previous send index 1 with salt 1. Without the salt we would have no
way of knowing for sure if it's the correct reply, but with we will know
for certain.
Through this conversion we also get several other benefits. We can now
more appropriately handle asynchronously sent messages by providing
space for a callback to be defined. This notably allows us to handle MAC
filter failures better; previously we could potentially have stale,
failed filters in our list, which shouldn't really have a major impact
but is obviously not correct. I also managed to remove fairly
significant more lines than I added which is a win in my book.
Additionally, this converts some variables to use auto-variables where
appropriate. This makes the alloc paths much cleaner and less prone to
memory leaks. We also fix a few virtchnl related bugs while we're here.
The following are changes since commit 09fcde54776180a76e99cae7f6d51b33c4a06525:
Merge branch 'mptcp-userspace-pm'
and are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/next-queue 200GbE
Alan Brady (11):
idpf: add idpf_virtchnl.h
idpf: implement virtchnl transaction manager
idpf: refactor vport virtchnl messages
idpf: refactor queue related virtchnl messages
idpf: refactor remaining virtchnl messages
idpf: add async_handler for MAC filter messages
idpf: refactor idpf_recv_mb_msg
idpf: cleanup virtchnl cruft
idpf: prevent deinit uninitialized virtchnl core
idpf: fix minor controlq issues
idpf: remove dealloc vector msg err in idpf_intr_rel
drivers/net/ethernet/intel/idpf/idpf.h | 146 +-
.../net/ethernet/intel/idpf/idpf_controlq.c | 7 +-
.../ethernet/intel/idpf/idpf_controlq_api.h | 5 +
drivers/net/ethernet/intel/idpf/idpf_dev.c | 1 +
drivers/net/ethernet/intel/idpf/idpf_lib.c | 39 +-
drivers/net/ethernet/intel/idpf/idpf_main.c | 6 +-
drivers/net/ethernet/intel/idpf/idpf_txrx.c | 1 +
drivers/net/ethernet/intel/idpf/idpf_vf_dev.c | 3 +-
.../net/ethernet/intel/idpf/idpf_virtchnl.c | 2278 ++++++++---------
.../net/ethernet/intel/idpf/idpf_virtchnl.h | 70 +
10 files changed, 1182 insertions(+), 1374 deletions(-)
create mode 100644 drivers/net/ethernet/intel/idpf/idpf_virtchnl.h
--
2.41.0
Powered by blists - more mailing lists