Commit 6689d716 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'MCTP-flow-support'



Jeremy Kerr says:

====================
MCTP flow support

For certain MCTP transport bindings, the binding driver will need to be
aware of request/response pairing. For example, the i2c binding may need
to set multiplexer configuration when expecting a response from a device
behind a mux.

This series implements a mechanism for informing the driver about these
flows, so it can implement transport-specific behaviour when a flow is
in progress (ie, a response is expected, and/or we time-out on that
expectation). We use a skb extension to notify the driver about the
presence of a flow, and a new dev->ops callback to notify about a flow's
destruction.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents e311eb91 67737c45
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4243,6 +4243,9 @@ enum skb_ext_id {
#endif
#if IS_ENABLED(CONFIG_MPTCP)
	SKB_EXT_MPTCP,
#endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
	SKB_EXT_MCTP,
#endif
	SKB_EXT_NUM, /* must be last */
};
+13 −0
Original line number Diff line number Diff line
@@ -152,6 +152,12 @@ struct mctp_sk_key {

	/* expiry timeout; valid (above) cleared on expiry */
	unsigned long	expiry;

	/* free to use for device flow state tracking. Initialised to
	 * zero on initial key creation
	 */
	unsigned long	dev_flow_state;
	struct mctp_dev	*dev;
};

struct mctp_skb_cb {
@@ -189,6 +195,13 @@ static inline struct mctp_skb_cb *mctp_cb(struct sk_buff *skb)
	return (void *)(skb->cb);
}

/* If CONFIG_MCTP_FLOWS, we may add one of these as a SKB extension,
 * indicating the flow to the device driver.
 */
struct mctp_flow {
	struct mctp_sk_key *key;
};

/* Route definition.
 *
 * These are held in the pernet->mctp.routes list, with RCU protection for
+16 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#include <linux/types.h>
#include <linux/refcount.h>

struct mctp_sk_key;

struct mctp_dev {
	struct net_device	*dev;

@@ -21,6 +23,8 @@ struct mctp_dev {

	unsigned int		net;

	const struct mctp_netdev_ops *ops;

	/* Only modified under RTNL. Reads have addrs_lock held */
	u8			*addrs;
	size_t			num_addrs;
@@ -29,12 +33,24 @@ struct mctp_dev {
	struct rcu_head		rcu;
};

struct mctp_netdev_ops {
	void			(*release_flow)(struct mctp_dev *dev,
						struct mctp_sk_key *key);
};

#define MCTP_INITIAL_DEFAULT_NET	1

struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev);
struct mctp_dev *__mctp_dev_get(const struct net_device *dev);

int mctp_register_netdev(struct net_device *dev,
			 const struct mctp_netdev_ops *ops);
void mctp_unregister_netdev(struct net_device *dev);

void mctp_dev_hold(struct mctp_dev *mdev);
void mctp_dev_put(struct mctp_dev *mdev);

void mctp_dev_set_key(struct mctp_dev *dev, struct mctp_sk_key *key);
void mctp_dev_release_key(struct mctp_dev *dev, struct mctp_sk_key *key);

#endif /* __NET_MCTPDEVICE_H */
+19 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@
#include <net/xfrm.h>
#include <net/mpls.h>
#include <net/mptcp.h>
#include <net/mctp.h>
#include <net/page_pool.h>

#include <linux/uaccess.h>
@@ -4440,6 +4441,9 @@ static const u8 skb_ext_type_len[] = {
#if IS_ENABLED(CONFIG_MPTCP)
	[SKB_EXT_MPTCP] = SKB_EXT_CHUNKSIZEOF(struct mptcp_ext),
#endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
	[SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow),
#endif
};

static __always_inline unsigned int skb_ext_total_length(void)
@@ -4456,6 +4460,9 @@ static __always_inline unsigned int skb_ext_total_length(void)
#endif
#if IS_ENABLED(CONFIG_MPTCP)
		skb_ext_type_len[SKB_EXT_MPTCP] +
#endif
#if IS_ENABLED(CONFIG_MCTP_FLOWS)
		skb_ext_type_len[SKB_EXT_MCTP] +
#endif
		0;
}
@@ -6529,6 +6536,14 @@ static void skb_ext_put_sp(struct sec_path *sp)
}
#endif

#ifdef CONFIG_MCTP_FLOWS
static void skb_ext_put_mctp(struct mctp_flow *flow)
{
	if (flow->key)
		mctp_key_unref(flow->key);
}
#endif

void __skb_ext_del(struct sk_buff *skb, enum skb_ext_id id)
{
	struct skb_ext *ext = skb->extensions;
@@ -6564,6 +6579,10 @@ void __skb_ext_put(struct skb_ext *ext)
	if (__skb_ext_exist(ext, SKB_EXT_SEC_PATH))
		skb_ext_put_sp(skb_ext_get_ptr(ext, SKB_EXT_SEC_PATH));
#endif
#ifdef CONFIG_MCTP_FLOWS
	if (__skb_ext_exist(ext, SKB_EXT_MCTP))
		skb_ext_put_mctp(skb_ext_get_ptr(ext, SKB_EXT_MCTP));
#endif

	kmem_cache_free(skbuff_ext_cache, ext);
}
+6 −1
Original line number Diff line number Diff line

menuconfig MCTP
	depends on NET
	tristate "MCTP core protocol support"
	bool "MCTP core protocol support"
	help
	  Management Component Transport Protocol (MCTP) is an in-system
	  protocol for communicating between management controllers and
@@ -16,3 +16,8 @@ config MCTP_TEST
        bool "MCTP core tests" if !KUNIT_ALL_TESTS
        depends on MCTP=y && KUNIT=y
        default KUNIT_ALL_TESTS

config MCTP_FLOWS
	bool
	depends on MCTP
	select SKB_EXTENSIONS
Loading