rds: add transport specific tos_map hook
authorSantosh Shilimkar <santosh.shilimkar@oracle.com>
Sat, 13 Oct 2018 13:36:49 +0000 (21:36 +0800)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Mon, 4 Feb 2019 22:59:13 +0000 (14:59 -0800)
RDMA transport maps user tos to underline virtual lanes(VL)
for IB or DSCP values. RDMA CM transport abstract thats for
RDS. TCP transport makes use of default priority 0 and maps
all user tos values to it.

Reviewed-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
[yanjun.zhu@oracle.com: Adapted original patch with ipv6 changes]
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
net/rds/af_rds.c
net/rds/ib.c
net/rds/rds.h
net/rds/tcp.c

index 9045158580370e0969c29b57cc3963982c769c62..d6cc97fbbbb02458d958a8f493e37e6249db4db6 100644 (file)
@@ -255,16 +255,18 @@ static __poll_t rds_poll(struct file *file, struct socket *sock,
 static int rds_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 {
        struct rds_sock *rs = rds_sk_to_rs(sock->sk);
-       rds_tos_t tos;
+       rds_tos_t utos, tos = 0;
 
        switch (cmd) {
        case SIOCRDSSETTOS:
-               if (get_user(tos, (rds_tos_t __user *)arg))
+               if (get_user(utos, (rds_tos_t __user *)arg))
                        return -EFAULT;
 
                if (rs->rs_transport &&
-                   rs->rs_transport->t_type == RDS_TRANS_TCP)
-                       tos = 0;
+                   rs->rs_transport->get_tos_map)
+                       tos = rs->rs_transport->get_tos_map(utos);
+               else
+                       return -ENOIOCTLCMD;
 
                spin_lock_bh(&rds_sock_lock);
                if (rs->rs_tos || rs->rs_conn) {
index 21b6588b71caa04d0ad1a5c6035ac9c28fb70973..2da9b75bad16a948c127ab7dc1b2f0dd559e0946 100644 (file)
@@ -515,6 +515,15 @@ void rds_ib_exit(void)
        rds_ib_mr_exit();
 }
 
+static u8 rds_ib_get_tos_map(u8 tos)
+{
+       /* 1:1 user to transport map for RDMA transport.
+        * In future, if custom map is desired, hook can export
+        * user configurable map.
+        */
+       return tos;
+}
+
 struct rds_transport rds_ib_transport = {
        .laddr_check            = rds_ib_laddr_check,
        .xmit_path_complete     = rds_ib_xmit_path_complete,
@@ -537,6 +546,7 @@ struct rds_transport rds_ib_transport = {
        .sync_mr                = rds_ib_sync_mr,
        .free_mr                = rds_ib_free_mr,
        .flush_mrs              = rds_ib_flush_mrs,
+       .get_tos_map            = rds_ib_get_tos_map,
        .t_owner                = THIS_MODULE,
        .t_name                 = "infiniband",
        .t_unloading            = rds_ib_is_unloading,
index 7e52b92092d718e5e3742bd6d5c0e70ddd42d77c..0d8f67cadd7476ddaaa4a693453486df073a4a12 100644 (file)
@@ -574,6 +574,7 @@ struct rds_transport {
        void (*free_mr)(void *trans_private, int invalidate);
        void (*flush_mrs)(void);
        bool (*t_unloading)(struct rds_connection *conn);
+       u8 (*get_tos_map)(u8 tos);
 };
 
 /* Bind hash table key length.  It is the sum of the size of a struct
index eb6851952cbf2084d290c40a50a0760c9f0d5471..fd2694174607405ab96f6f0dea10bc8dcc8caea9 100644 (file)
@@ -453,6 +453,12 @@ static void rds_tcp_destroy_conns(void)
 
 static void rds_tcp_exit(void);
 
+static u8 rds_tcp_get_tos_map(u8 tos)
+{
+       /* all user tos mapped to default 0 for TCP transport */
+       return 0;
+}
+
 struct rds_transport rds_tcp_transport = {
        .laddr_check            = rds_tcp_laddr_check,
        .xmit_path_prepare      = rds_tcp_xmit_path_prepare,
@@ -467,6 +473,7 @@ struct rds_transport rds_tcp_transport = {
        .inc_free               = rds_tcp_inc_free,
        .stats_info_copy        = rds_tcp_stats_info_copy,
        .exit                   = rds_tcp_exit,
+       .get_tos_map            = rds_tcp_get_tos_map,
        .t_owner                = THIS_MODULE,
        .t_name                 = "tcp",
        .t_type                 = RDS_TRANS_TCP,