Add support for setting priorities provided by DCB in the kernel. This implementation does not track any priority changes which could occur over time.
Signed-off-by: Mark Rustad <[email protected]> --- usr/Makefile | 4 +++- usr/io.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletions(-) diff --git a/usr/Makefile b/usr/Makefile index b02a706..991efd9 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -21,10 +21,12 @@ ifeq ($(OSNAME),Linux) endif endif IPC_OBJ=netlink.o +DCB_OBJ=dcb_app.o else ifeq ($(OSNAME),FreeBSD) IPC_CFLAGS= IPC_OBJ=ioctl.o +DCB_OBJ= endif endif @@ -39,7 +41,7 @@ SYSDEPS_SRCS = $(wildcard ../utils/sysdeps/*.o) # sources shared between iscsid, iscsiadm and iscsistart ISCSI_LIB_SRCS = iscsi_util.o io.o auth.o login.o log.o md5.o sha1.o iface.o \ idbm.o sysfs.o host.o session_info.o iscsi_sysfs.o iscsi_net_util.o \ - iscsid_req.o $(SYSDEPS_SRCS) + iscsid_req.o $(SYSDEPS_SRCS) $(DCB_OBJ) # core initiator files INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o \ transport.o cxgbi.o be2iscsi.o diff --git a/usr/io.c b/usr/io.c index 8fb806d..8ecef6c 100644 --- a/usr/io.c +++ b/usr/io.c @@ -31,6 +31,7 @@ #include "types.h" #include "iscsi_proto.h" +#include "iscsi_settings.h" #include "initiator.h" #include "iscsi_ipc.h" #include "log.h" @@ -38,6 +39,7 @@ #include "idbm.h" #include "iface.h" #include "sysdeps.h" +#include "dcb_app.h" #define LOG_CONN_CLOSED(conn) \ do { \ @@ -76,6 +78,27 @@ set_non_blocking(int fd) } +#ifdef Linux +static int select_priority(iscsi_conn_t *conn, int pri_mask) +{ + int msk; + + if (!pri_mask) + return 0; + + /* + * TODO: Configure priority selection from the mask + * For now, just always take the highest + */ + + /* Find highest bit set */ + while ((msk = pri_mask & (pri_mask - 1))) + pri_mask = msk; + + return ffs(pri_mask) - 1; +} +#endif /* Linux */ + #if 0 /* not used by anyone */ static int get_hwaddress_from_netdev(char *netdev, char *hwaddress) @@ -320,6 +343,27 @@ iscsi_io_tcp_connect(iscsi_conn_t *conn, int non_blocking) log_debug(1, "connecting to %s:%s", conn->host, serv); if (non_blocking) set_non_blocking(conn->socket_fd); + +#ifdef Linux + int pri_mask = 0; + + if (conn->session->netdev[0]) + pri_mask = get_dcb_app_pri_by_port(conn->session->netdev, + ISCSI_DEFAULT_PORT); + if (pri_mask < 0) + log_debug(2, "Getting priority for %s returned %d", + conn->session->netdev, pri_mask); + else if (pri_mask == 0) + log_debug(2, "No priority for %s", conn->session->netdev); + else { + int pri = select_priority(conn, pri_mask); + + log_debug(1, "Setting socket priority to %d", pri); + rc = setsockopt(conn->socket_fd, SOL_SOCKET, + SO_PRIORITY, &pri, sizeof(pri)); + } +#endif /* Linux */ + rc = connect(conn->socket_fd, (struct sockaddr *) ss, sizeof (*ss)); return rc; } -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
