#include "connectivity.h"
#include "netdev.h"
+#include "netdev-offload.h"
#include "openvswitch/list.h"
#include "ovs-numa.h"
+#include "ovs-rcu.h"
#include "packets.h"
#include "seq.h"
#include "openvswitch/shash.h"
struct netdev_tnl_build_header_params;
#define NETDEV_NUMA_UNSPEC OVS_NUMA_UNSPEC
+enum netdev_ol_flags {
+ NETDEV_TX_OFFLOAD_IPV4_CKSUM = 1 << 0,
+ NETDEV_TX_OFFLOAD_TCP_CKSUM = 1 << 1,
+ NETDEV_TX_OFFLOAD_UDP_CKSUM = 1 << 2,
+ NETDEV_TX_OFFLOAD_SCTP_CKSUM = 1 << 3,
+ NETDEV_TX_OFFLOAD_TCP_TSO = 1 << 4,
+};
+
/* A network device (e.g. an Ethernet device).
*
* Network device implementations may read these members but should not modify
* opening this device, and therefore got assigned to the "system" class */
bool auto_classified;
+ /* This bitmask of the offloading features enabled by the netdev. */
+ uint64_t ol_flags;
+
/* If this is 'true', the user explicitly specified an MTU for this
* netdev. Otherwise, Open vSwitch is allowed to override it. */
bool mtu_user_config;
*
* Minimally, the sequence number is required to change whenever
* 'netdev''s flags, features, ethernet address, or carrier changes. */
- uint64_t change_seq;
+ atomic_uint64_t change_seq;
/* A netdev provider might be unable to change some of the device's
* parameter (n_rxq, mtu) when the device is in use. In this case
int n_rxq;
struct shash_node *node; /* Pointer to element in global map. */
struct ovs_list saved_flags_list; /* Contains "struct netdev_saved_flags". */
+
+ /* Functions to control flow offloading. */
+ OVSRCU_TYPE(const struct netdev_flow_api *) flow_api;
+ const char *dpif_type; /* Type of dpif this netdev belongs to. */
+ struct netdev_hw_info hw_info; /* Offload-capable netdev info. */
};
static inline void
netdev_change_seq_changed(const struct netdev *netdev_)
{
+ uint64_t change_seq;
struct netdev *netdev = CONST_CAST(struct netdev *, netdev_);
seq_change(connectivity_seq_get());
- netdev->change_seq++;
- if (!netdev->change_seq) {
- netdev->change_seq++;
+
+ atomic_read_relaxed(&netdev->change_seq, &change_seq);
+ change_seq++;
+ if (OVS_UNLIKELY(!change_seq)) {
+ change_seq++;
}
+ atomic_store_explicit(&netdev->change_seq, change_seq,
+ memory_order_release);
}
static inline void
struct netdev *netdev_rxq_get_netdev(const struct netdev_rxq *);
-struct netdev_flow_dump {
- struct netdev *netdev;
- odp_port_t port;
- bool terse;
- struct nl_dump *nl_dump;
-};
-
/* Network device class structure, to be defined by each implementation of a
* network device.
*
void (*rxq_destruct)(struct netdev_rxq *);
void (*rxq_dealloc)(struct netdev_rxq *);
+ /* Retrieves the current state of rx queue. 'false' means that queue won't
+ * get traffic in a short term and could be not polled.
+ *
+ * This function may be set to null if it would always return 'true'
+ * anyhow. */
+ bool (*rxq_enabled)(struct netdev_rxq *);
+
/* Attempts to receive a batch of packets from 'rx'. In 'batch', the
* caller supplies 'packets' as the pointer to the beginning of an array
* of NETDEV_MAX_BURST pointers to dp_packet. If successful, the
/* Discards all packets waiting to be received from 'rx'. */
int (*rxq_drain)(struct netdev_rxq *rx);
- /* ## -------------------------------- ## */
- /* ## netdev flow offloading functions ## */
- /* ## -------------------------------- ## */
-
- /* If a particular netdev class does not support offloading flows,
- * all these function pointers must be NULL. */
-
- /* Flush all offloaded flows from a netdev.
- * Return 0 if successful, otherwise returns a positive errno value. */
- int (*flow_flush)(struct netdev *);
-
- /* Flow dumping interface.
- *
- * This is the back-end for the flow dumping interface described in
- * dpif.h. Please read the comments there first, because this code
- * closely follows it.
- *
- * On success returns 0 and allocates data, on failure returns
- * positive errno. */
- int (*flow_dump_create)(struct netdev *, struct netdev_flow_dump **dump);
- int (*flow_dump_destroy)(struct netdev_flow_dump *);
-
- /* Returns true if there are more flows to dump.
- * 'rbuffer' is used as a temporary buffer and needs to be pre allocated
- * by the caller. While there are more flows the same 'rbuffer'
- * should be provided. 'wbuffer' is used to store dumped actions and needs
- * to be pre allocated by the caller. */
- bool (*flow_dump_next)(struct netdev_flow_dump *, struct match *,
- struct nlattr **actions,
- struct dpif_flow_stats *stats, ovs_u128 *ufid,
- struct ofpbuf *rbuffer, struct ofpbuf *wbuffer);
-
- /* Offload the given flow on netdev.
- * To modify a flow, use the same ufid.
- * 'actions' are in netlink format, as with struct dpif_flow_put.
- * 'info' is extra info needed to offload the flow.
- * 'stats' is populated according to the rules set out in the description
- * above 'struct dpif_flow_put'.
- * Return 0 if successful, otherwise returns a positive errno value. */
- int (*flow_put)(struct netdev *, struct match *, struct nlattr *actions,
- size_t actions_len, const ovs_u128 *ufid,
- struct offload_info *info, struct dpif_flow_stats *);
-
- /* Queries a flow specified by ufid on netdev.
- * Fills output buffer as 'wbuffer' in flow_dump_next, which
- * needs to be be pre allocated.
- * Return 0 if successful, otherwise returns a positive errno value. */
- int (*flow_get)(struct netdev *, struct match *, struct nlattr **actions,
- const ovs_u128 *ufid, struct dpif_flow_stats *,
- struct ofpbuf *wbuffer);
-
- /* Delete a flow specified by ufid from netdev.
- * 'stats' is populated according to the rules set out in the description
- * above 'struct dpif_flow_del'.
- * Return 0 if successful, otherwise returns a positive errno value. */
- int (*flow_del)(struct netdev *, const ovs_u128 *ufid,
- struct dpif_flow_stats *);
-
- /* Initializies the netdev flow api.
- * Return 0 if successful, otherwise returns a positive errno value. */
- int (*init_flow_api)(struct netdev *);
+ /* Get a block_id from the netdev.
+ * Returns the block_id or 0 if none exists for netdev. */
+ uint32_t (*get_block_id)(struct netdev *);
};
int netdev_register_provider(const struct netdev_class *);
extern const struct netdev_class netdev_internal_class;
extern const struct netdev_class netdev_tap_class;
+#ifdef HAVE_AF_XDP
+extern const struct netdev_class netdev_afxdp_class;
+extern const struct netdev_class netdev_afxdp_nonpmd_class;
+#endif
#ifdef __cplusplus
}
#endif
-#define NO_OFFLOAD_API NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-
#endif /* netdev.h */