Commit bc877956 authored by Amritha Nambiar's avatar Amritha Nambiar Committed by Jakub Kicinski
Browse files

netdev-genl: spec: Extend netdev netlink spec in YAML for queue



Add support in netlink spec(netdev.yaml) for queue information.
Add code generated from the spec.

Note: The "queue-type" attribute takes values 0 and 1 for rx
and tx queue type respectively.

Signed-off-by: default avatarAmritha Nambiar <amritha.nambiar@intel.com>
Reviewed-by: default avatarSridhar Samudrala <sridhar.samudrala@intel.com>
Link: https://lore.kernel.org/r/170147330963.5260.2576294626647300472.stgit@anambiarhost.jf.intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3706f141
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -66,6 +66,10 @@ definitions:
        name: tx-checksum
        doc:
          L3 checksum HW offload is supported by the driver.
  -
    name: queue-type
    type: enum
    entries: [ rx, tx ]

attribute-sets:
  -
@@ -209,6 +213,31 @@ attribute-sets:
        name: recycle-released-refcnt
        type: uint

  -
    name: queue
    attributes:
      -
        name: id
        doc: Queue index; most queue types are indexed like a C array, with
             indexes starting at 0 and ending at queue count - 1. Queue indexes
             are scoped to an interface and queue type.
        type: u32
      -
        name: ifindex
        doc: ifindex of the netdevice to which the queue belongs.
        type: u32
        checks:
          min: 1
      -
        name: type
        doc: Queue type as rx, tx. Each queue type defines a separate ID space.
        type: u32
        enum: queue-type
      -
        name: napi-id
        doc: ID of the NAPI instance which services this queue.
        type: u32

operations:
  list:
    -
@@ -307,6 +336,29 @@ operations:
      dump:
        reply: *pp-stats-reply
      config-cond: page-pool-stats
    -
      name: queue-get
      doc: Get queue information from the kernel.
           Only configured queues will be reported (as opposed to all available
           hardware queues).
      attribute-set: queue
      do:
        request:
          attributes:
            - ifindex
            - type
            - id
        reply: &queue-get-op
          attributes:
            - id
            - type
            - napi-id
            - ifindex
      dump:
        request:
          attributes:
            - ifindex
        reply: *queue-get-op

mcast-groups:
  list:
+16 −0
Original line number Diff line number Diff line
@@ -62,6 +62,11 @@ enum netdev_xsk_flags {
	NETDEV_XSK_FLAGS_TX_CHECKSUM = 2,
};

enum netdev_queue_type {
	NETDEV_QUEUE_TYPE_RX,
	NETDEV_QUEUE_TYPE_TX,
};

enum {
	NETDEV_A_DEV_IFINDEX = 1,
	NETDEV_A_DEV_PAD,
@@ -104,6 +109,16 @@ enum {
	NETDEV_A_PAGE_POOL_STATS_MAX = (__NETDEV_A_PAGE_POOL_STATS_MAX - 1)
};

enum {
	NETDEV_A_QUEUE_ID = 1,
	NETDEV_A_QUEUE_IFINDEX,
	NETDEV_A_QUEUE_TYPE,
	NETDEV_A_QUEUE_NAPI_ID,

	__NETDEV_A_QUEUE_MAX,
	NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
};

enum {
	NETDEV_CMD_DEV_GET = 1,
	NETDEV_CMD_DEV_ADD_NTF,
@@ -114,6 +129,7 @@ enum {
	NETDEV_CMD_PAGE_POOL_DEL_NTF,
	NETDEV_CMD_PAGE_POOL_CHANGE_NTF,
	NETDEV_CMD_PAGE_POOL_STATS_GET,
	NETDEV_CMD_QUEUE_GET,

	__NETDEV_CMD_MAX,
	NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1)
+26 −0
Original line number Diff line number Diff line
@@ -46,6 +46,18 @@ static const struct nla_policy netdev_page_pool_stats_get_nl_policy[NETDEV_A_PAG
};
#endif /* CONFIG_PAGE_POOL_STATS */

/* NETDEV_CMD_QUEUE_GET - do */
static const struct nla_policy netdev_queue_get_do_nl_policy[NETDEV_A_QUEUE_TYPE + 1] = {
	[NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
	[NETDEV_A_QUEUE_TYPE] = NLA_POLICY_MAX(NLA_U32, 1),
	[NETDEV_A_QUEUE_ID] = { .type = NLA_U32, },
};

/* NETDEV_CMD_QUEUE_GET - dump */
static const struct nla_policy netdev_queue_get_dump_nl_policy[NETDEV_A_QUEUE_IFINDEX + 1] = {
	[NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
};

/* Ops table for netdev */
static const struct genl_split_ops netdev_nl_ops[] = {
	{
@@ -88,6 +100,20 @@ static const struct genl_split_ops netdev_nl_ops[] = {
		.flags	= GENL_CMD_CAP_DUMP,
	},
#endif /* CONFIG_PAGE_POOL_STATS */
	{
		.cmd		= NETDEV_CMD_QUEUE_GET,
		.doit		= netdev_nl_queue_get_doit,
		.policy		= netdev_queue_get_do_nl_policy,
		.maxattr	= NETDEV_A_QUEUE_TYPE,
		.flags		= GENL_CMD_CAP_DO,
	},
	{
		.cmd		= NETDEV_CMD_QUEUE_GET,
		.dumpit		= netdev_nl_queue_get_dumpit,
		.policy		= netdev_queue_get_dump_nl_policy,
		.maxattr	= NETDEV_A_QUEUE_IFINDEX,
		.flags		= GENL_CMD_CAP_DUMP,
	},
};

static const struct genl_multicast_group netdev_nl_mcgrps[] = {
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ int netdev_nl_page_pool_stats_get_doit(struct sk_buff *skb,
				       struct genl_info *info);
int netdev_nl_page_pool_stats_get_dumpit(struct sk_buff *skb,
					 struct netlink_callback *cb);
int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info);
int netdev_nl_queue_get_dumpit(struct sk_buff *skb,
			       struct netlink_callback *cb);

enum {
	NETDEV_NLGRP_MGMT,
+10 −0
Original line number Diff line number Diff line
@@ -140,6 +140,16 @@ int netdev_nl_dev_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
	return skb->len;
}

int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info)
{
	return -EOPNOTSUPP;
}

int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
{
	return -EOPNOTSUPP;
}

static int netdev_genl_netdevice_event(struct notifier_block *nb,
				       unsigned long event, void *ptr)
{
Loading