]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - rdma/rdma.h
rdma: Provide and reuse filter functions
[mirror_iproute2.git] / rdma / rdma.h
index c3b7530b6cc7125a4764c65ff2968106210f595d..1022e9a29291d49896ebf9d103e9c0345792e23b 100644 (file)
@@ -1,11 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
 /*
  * rdma.c      RDMA tool
- *
- *              This program is free software; you can redistribute it and/or
- *              modify it under the terms of the GNU General Public License
- *              as published by the Free Software Foundation; either version
- *              2 of the License, or (at your option) any later version.
- *
  * Authors:     Leon Romanovsky <leonro@mellanox.com>
  */
 #ifndef _RDMA_TOOL_H_
 #define MAX_NUMBER_OF_FILTERS 64
 struct filters {
        const char *name;
-       bool is_number;
+       uint8_t is_number:1;
+       uint8_t is_doit:1;
 };
 
 struct filter_entry {
        struct list_head list;
        char *key;
        char *value;
+       /*
+        * This field menas that we can try to issue .doit calback
+        * on value above. This value can be converted to integer
+        * with simple atoi(). Otherwise "is_doit" will be false.
+        */
+       uint8_t is_doit:1;
 };
 
 struct dev_map {
@@ -90,6 +92,7 @@ int cmd_link(struct rd *rd);
 int cmd_res(struct rd *rd);
 int rd_exec_cmd(struct rd *rd, const struct rd_cmd *c, const char *str);
 int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd));
+int rd_exec_require_dev(struct rd *rd, int (*cb)(struct rd *rd));
 int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port);
 void rd_free(struct rd *rd);
 int rd_set_arg_to_devname(struct rd *rd);
@@ -105,10 +108,12 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index);
 /*
  * Filter manipulation
  */
+bool rd_doit_index(struct rd *rd, uint32_t *idx);
 int rd_build_filter(struct rd *rd, const struct filters valid_filters[]);
-bool rd_check_is_filtered(struct rd *rd, const char *key, uint32_t val);
-bool rd_check_is_string_filtered(struct rd *rd, const char *key, const char *val);
-bool rd_check_is_key_exist(struct rd *rd, const char *key);
+bool rd_is_filtered_attr(struct rd *rd, const char *key, uint32_t val,
+                        struct nlattr *attr);
+bool rd_is_string_filtered_attr(struct rd *rd, const char *key, const char *val,
+                               struct nlattr *attr);
 /*
  * Netlink
  */