[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:43:25 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit 8f133f7c2d65a8398a95cd15de14f1586cc91d86
Author: Mark Rustad <mark.d.rustad at intel.com>
Date:   Mon Jun 20 11:50:27 2011 -0700

    iscsid: Add IEEE DCB support
    
    Add IEEE DCB support. This still has the same limitations as the existing
    DCB support, in that it cannot dynamically track priority changes if the
    configuration, or even the routing, changes over time, but it provides
    equivalent support for systems running with 802.1Qaz as the current DCB
    support in iscsid. This should still support CEE when run on kernels that
    do not support IEEE.
    
    v2: Add omitted Tested-by credit.
    
    Tested-by: Ross Brattain <ross.b.brattain at intel.com>
    Signed-off-by: Mark Rustad <mark.d.rustad at intel.com>

diff --git a/usr/dcb_app.c b/usr/dcb_app.c
index 0131b09..78a5cd1 100644
--- a/usr/dcb_app.c
+++ b/usr/dcb_app.c
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   DCB application support
-  Copyright(c) 2007-2010 Intel Corporation.
+  Copyright(c) 2007-2011 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,8 +20,7 @@
   the file called "COPYING".
 
   Contact Information:
-  e1000-eedc Mailing List <e1000-eedc at lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+  open-lldp Mailing List <lldp-devel at open-lldp.org>
 
 *******************************************************************************/
 
@@ -39,7 +38,13 @@
 #include "dcb_app.h"
 #include "sysfs.h"
 
-#define NLA_DATA(nla)        ((void *)((char*)(nla) + NLA_HDRLEN))
+#define IEEE_SMASK_ETHTYPE	(1 << IEEE_8021QAZ_APP_SEL_ETHERTYPE)
+#define IEEE_SMASK_STREAM	(1 << IEEE_8021QAZ_APP_SEL_STREAM)
+#define IEEE_SMASK_DGRAM	(1 << IEEE_8021QAZ_APP_SEL_DGRAM)
+#define IEEE_SMASK_ANY		(1 << IEEE_8021QAZ_APP_SEL_ANY)
+
+#define NLA_DATA(nla)        ((void *)((char *)(nla) + NLA_HDRLEN))
+#define NLA_NEXT(nla) (struct rtattr *)((char *)nla + NLMSG_ALIGN(nla->rta_len))
 
 /* Maximum size of response requested or message sent */
 #define MAX_MSG_SIZE    1024
@@ -72,7 +77,7 @@ static struct nlmsghdr *start_dcbmsg(__u16 msg_type, __u8 arg)
 }
 
 static struct rtattr *add_rta(struct nlmsghdr *nlh, __u16 rta_type,
-                              void *attr, __u16 rta_len)
+			      void *attr, __u16 rta_len)
 {
 	struct rtattr *rta;
 
@@ -127,14 +132,49 @@ static struct nlmsghdr *dcbnl_get_msg(int nl_sd)
 	return nlh;
 }
 
-static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
+static int get_dcbx_cap(int nl_sd, const char *ifname)
+{
+	struct nlmsghdr *nlh;
+	struct dcbmsg *d;
+	struct rtattr *rta;
+	int rval;
+
+	nlh = start_dcbmsg(RTM_GETDCB, DCB_CMD_GDCBX);
+	if (!nlh)
+		return -EIO;
+
+	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
+	rval = dcbnl_send_msg(nl_sd, nlh);
+	free(nlh);
+	if (rval)
+		return -EIO;
+
+	/* Receive DCBX capabilities */
+	nlh = dcbnl_get_msg(nl_sd);
+	if (!nlh)
+		return -EIO;
+
+	d = (struct dcbmsg *)NLMSG_DATA(nlh);
+	rta = (struct rtattr *)(((char *)d) +
+			NLMSG_ALIGN(sizeof(struct dcbmsg)));
+
+	if (d->cmd != DCB_CMD_GDCBX || rta->rta_type != DCB_ATTR_DCBX) {
+		free(nlh);
+		return -EIO;
+	}
+
+	rval = *(__u8 *)NLA_DATA(rta);
+	free(nlh);
+	return rval;
+}
+
+static int get_cee_app_pri(int nl_sd, const char *ifname,
+			   __u8 req_idtype, __u16 req_id)
 {
 	struct nlmsghdr *nlh;
 	struct dcbmsg *d;
 	struct rtattr *rta_parent, *rta_child;
 	int rval = 0;
-	int nl_sd;
-	unsigned int seq;
 	__u8 idtype;
 	__u16 id;
 
@@ -142,7 +182,6 @@ static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
 	if (!nlh)
 		return -EIO;
 
-	seq = nlh->nlmsg_seq;
 	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
 	rta_parent = add_rta(nlh, DCB_ATTR_APP, NULL, 0);
 
@@ -154,19 +193,12 @@ static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
 		(void *)&req_id, sizeof(__u16));
 	rta_parent->rta_len += NLA_ALIGN(rta_child->rta_len);
 
-	nl_sd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
-	if (nl_sd < 0)
-		return nl_sd;
-
 	rval = dcbnl_send_msg(nl_sd, nlh);
 	free(nlh);
-	if (rval) {
-		close(nl_sd);
+	if (rval)
 		return -EIO;
-	}
 
 	nlh = dcbnl_get_msg(nl_sd);
-	close(nl_sd);
 	if (!nlh)
 		return -EIO;
 
@@ -184,28 +216,100 @@ static int get_app_cfg(const char *ifname, __u8 req_idtype, __u16 req_id)
 	}
 
 	rta_child = NLA_DATA(rta_parent);
-	rta_parent = (struct rtattr *)((char *)rta_parent +
-	                               NLMSG_ALIGN(rta_parent->rta_len));
+	rta_parent = NLA_NEXT(rta_parent);
 
 	idtype = *(__u8 *)NLA_DATA(rta_child);
-	rta_child = (struct rtattr *)((char *)rta_child +
-		             NLMSG_ALIGN(rta_child->rta_len));
+	rta_child = NLA_NEXT(rta_child);
 	if (idtype != req_idtype) {
 		rval = -EIO;
 		goto get_error;
 	}
 
 	id = *(__u16 *)NLA_DATA(rta_child);
-	rta_child = (struct rtattr *)((char *)rta_child +
-		             NLMSG_ALIGN(rta_child->rta_len));
+	rta_child = NLA_NEXT(rta_child);
 	if (id != req_id) {
 		rval = -EIO;
 		goto get_error;
 	}
 
 	rval = *(__u8 *)NLA_DATA(rta_child);
-	rta_child = (struct rtattr *)((char *)rta_child +
-		             NLMSG_ALIGN(rta_child->rta_len));
+
+get_error:
+	free(nlh);
+	return rval;
+}
+
+static int
+get_ieee_app_pri(int nl_sd, const char *ifname, __u8 ieee_mask, __u16 req_id)
+{
+	struct nlmsghdr *nlh;
+	struct dcbmsg *d;
+	struct rtattr *rta_parent, *rta_child;
+	int rval;
+
+	nlh = start_dcbmsg(RTM_GETDCB, DCB_CMD_IEEE_GET);
+	if (!nlh)
+		return -EIO;
+
+	add_rta(nlh, DCB_ATTR_IFNAME, (void *)ifname, strlen(ifname) + 1);
+
+	rval = dcbnl_send_msg(nl_sd, nlh);
+	free(nlh);
+	if (rval)
+		return -EIO;
+
+	nlh = dcbnl_get_msg(nl_sd);
+	if (!nlh)
+		return -EIO;
+
+	d = (struct dcbmsg *)NLMSG_DATA(nlh);
+	rta_parent = (struct rtattr *)(((char *)d) +
+		NLMSG_ALIGN(sizeof(struct dcbmsg)));
+
+	if (d->cmd != DCB_CMD_IEEE_GET) {
+		rval = -EIO;
+		goto get_error;
+	}
+	if (rta_parent->rta_type != DCB_ATTR_IFNAME) {
+		rval = -EIO;
+		goto get_error;
+	}
+
+	rta_parent = NLA_NEXT(rta_parent);
+
+	if (rta_parent->rta_type != DCB_ATTR_IEEE) {
+		rval = -EIO;
+		goto get_error;
+	}
+
+	rta_child = NLA_DATA(rta_parent);
+	rta_parent = NLA_NEXT(rta_parent);
+
+	for (; rta_parent > rta_child; rta_child = NLA_NEXT(rta_child)) {
+		if (rta_child->rta_type == DCB_ATTR_IEEE_APP_TABLE)
+			break;
+	}
+	if (rta_parent <= rta_child) {
+		rval = -EIO;
+		goto get_error;
+	}
+
+	rta_parent = rta_child;
+	rta_child = NLA_DATA(rta_parent);
+	rta_parent = NLA_NEXT(rta_parent);
+
+	rval = 0;
+	for (; rta_parent > rta_child; rta_child = NLA_NEXT(rta_child)) {
+		struct dcb_app *app;
+
+		if (rta_child->rta_type != DCB_ATTR_IEEE_APP)
+			continue;
+		app = (struct dcb_app *)NLA_DATA(rta_child);
+		if (app->protocol != req_id)
+			continue;
+		if ((1 << app->selector) & ieee_mask)
+			rval |= 1 << app->priority;
+	}
 
 get_error:
 	free(nlh);
@@ -225,22 +329,51 @@ static int get_link_ifname(const char *ifname, char *link_ifname)
 	return 0;
 }
 
-int get_dcb_app_pri_by_port(const char *ifname, int port)
+static int get_app_pri(const char *iface, __u8 req_idtype, __u16 req_id,
+		       __u8 ieee_mask)
 {
-	char link_ifname[IFNAMSIZ];
+	int dcbx_cap;
+	int pri;
+	int nl_sd;
+	char ifname[IFNAMSIZ];
 
-	if (get_link_ifname(ifname, link_ifname))
+	if (get_link_ifname(iface, ifname))
 		return 0;
 
-	return get_app_cfg(link_ifname, DCB_APP_IDTYPE_PORTNUM, port);
+	nl_sd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+	if (nl_sd < 0)
+		return -errno;
+
+	dcbx_cap = get_dcbx_cap(nl_sd, ifname);
+	if (dcbx_cap < 0 || !(dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
+		pri = get_cee_app_pri(nl_sd, ifname, req_idtype, req_id);
+	else
+		pri = get_ieee_app_pri(nl_sd, ifname, ieee_mask, req_id);
+
+	close(nl_sd);
+	return pri;
 }
 
-int get_dcb_app_pri_by_ethtype(const char *ifname, int ethtype)
+int get_dcb_app_pri_by_stream_port(const char *ifname, int port)
 {
-	char link_ifname[IFNAMSIZ];
+	return get_app_pri(ifname, DCB_APP_IDTYPE_PORTNUM, port,
+			IEEE_SMASK_STREAM | IEEE_SMASK_ANY);
+}
 
-	if (get_link_ifname(ifname, link_ifname))
-		return 0;
+int get_dcb_app_pri_by_datagram_port(const char *ifname, int port)
+{
+	return get_app_pri(ifname, DCB_APP_IDTYPE_PORTNUM, port,
+			IEEE_SMASK_DGRAM | IEEE_SMASK_ANY);
+}
+
+int get_dcb_app_pri_by_port_sel(const char *ifname, int port, int sel)
+{
+	return get_app_pri(ifname, DCB_APP_IDTYPE_PORTNUM, port,
+			1 << sel);
+}
 
-	return get_app_cfg(link_ifname, DCB_APP_IDTYPE_ETHTYPE, ethtype);
+int get_dcb_app_pri_by_ethtype(const char *ifname, int ethtype)
+{
+	return get_app_pri(ifname, DCB_APP_IDTYPE_ETHTYPE, ethtype,
+			IEEE_SMASK_ETHTYPE);
 }
diff --git a/usr/dcb_app.h b/usr/dcb_app.h
index 2e756f1..b8e55ca 100644
--- a/usr/dcb_app.h
+++ b/usr/dcb_app.h
@@ -1,7 +1,7 @@
 /*******************************************************************************
 
   DCB application support
-  Copyright(c) 2007-2010 Intel Corporation.
+  Copyright(c) 2010-2011 Intel Corporation.
 
   This program is free software; you can redistribute it and/or modify it
   under the terms and conditions of the GNU General Public License,
@@ -20,15 +20,22 @@
   the file called "COPYING".
 
   Contact Information:
-  e1000-eedc Mailing List <e1000-eedc at lists.sourceforge.net>
-  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+  open-lldp Mailing List <lldp-devel at open-lldp.org>
 
 *******************************************************************************/
 
 #ifndef _DCB_APP_H_
 #define _DCB_APP_H_
 
-int get_dcb_app_pri_by_port(const char *iface, int port);
-int get_dcb_app_pri_by_ethtype(const char *iface, int ethtype);
+int get_dcb_app_pri_by_ethtype(const char *ifname, int ethtype);
+
+int get_dcb_app_pri_by_stream_port(const char *ifname, int port);
+int get_dcb_app_pri_by_datagram_port(const char *ifname, int port);
+
+/*
+ * The selector values for the following call are defined in recent versions
+ * of the dcbnl.h file.
+ */
+int get_dcb_app_pri_by_port_sel(const char *ifname, int port, int sel);
 
 #endif  /* _DCB_APP_H_ */
diff --git a/usr/dcbnl.h b/usr/dcbnl.h
index 063ded9..2216e63 100644
--- a/usr/dcbnl.h
+++ b/usr/dcbnl.h
@@ -1,7 +1,7 @@
 /*
  * Local copy of the kernel's dcbnl.h
  *
- * Copyright (c) 2008, Intel Corporation.
+ * Copyright (c) 2008-2011, Intel Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -28,13 +28,13 @@
 #define IEEE_8021QAZ_MAX_TCS	8
 
 #define IEEE_8021QAZ_TSA_STRICT		0
-#define IEEE_8021QAZ_TSA_CB_SHABER	1
+#define IEEE_8021QAZ_TSA_CB_SHAPER	1
 #define IEEE_8021QAZ_TSA_ETS		2
 #define IEEE_8021QAZ_TSA_VENDOR		255
 
 /* This structure contains the IEEE 802.1Qaz ETS managed object
  *
- * @willing: willing bit in ETS configuratin TLV
+ * @willing: willing bit in ETS configuration TLV
  * @ets_cap: indicates supported capacity of ets feature
  * @cbs: credit based shaper ets algorithm supported
  * @tc_tx_bw: tc tx bandwidth indexed by traffic class
@@ -89,6 +89,50 @@ struct ieee_pfc {
 	__u64	indications[IEEE_8021QAZ_MAX_TCS];
 };
 
+/* CEE DCBX std supported values */
+#define CEE_DCBX_MAX_PGS	8
+#define CEE_DCBX_MAX_PRIO	8
+
+/**
+ * struct cee_pg - CEE Priority-Group managed object
+ *
+ * @willing: willing bit in the PG tlv
+ * @error: error bit in the PG tlv
+ * @pg_en: enable bit of the PG feature
+ * @tcs_supported: number of traffic classes supported
+ * @pg_bw: bandwidth percentage for each priority group
+ * @prio_pg: priority to PG mapping indexed by priority
+ */
+struct cee_pg {
+	__u8    willing;
+	__u8    error;
+	__u8    pg_en;
+	__u8    tcs_supported;
+	__u8    pg_bw[CEE_DCBX_MAX_PGS];
+	__u8    prio_pg[CEE_DCBX_MAX_PGS];
+};
+
+/**
+ * struct cee_pfc - CEE PFC managed object
+ *
+ * @willing: willing bit in the PFC tlv
+ * @error: error bit in the PFC tlv
+ * @pfc_en: bitmap indicating pfc enabled traffic classes
+ * @tcs_supported: number of traffic classes supported
+ */
+struct cee_pfc {
+	__u8    willing;
+	__u8    error;
+	__u8    pfc_en;
+	__u8    tcs_supported;
+};
+
+/* IEEE 802.1Qaz std supported values */
+#define IEEE_8021QAZ_APP_SEL_ETHERTYPE	1
+#define IEEE_8021QAZ_APP_SEL_STREAM	2
+#define IEEE_8021QAZ_APP_SEL_DGRAM	3
+#define IEEE_8021QAZ_APP_SEL_ANY	4
+
 /* This structure contains the IEEE 802.1Qaz APP managed object. This
  * object is also used for the CEE std as well. There is no difference
  * between the objects.
@@ -112,6 +156,20 @@ struct dcb_app {
 	__u16	protocol;
 };
 
+/**
+ * struct dcb_peer_app_info - APP feature information sent by the peer
+ *
+ * @willing: willing bit in the peer APP tlv
+ * @error: error bit in the peer APP tlv
+ *
+ * In addition to this information the full peer APP tlv also contains
+ * a table of 'app_count' APP objects defined above.
+ */
+struct dcb_peer_app_info {
+	__u8	willing;
+	__u8	error;
+};
+
 struct dcbmsg {
 	__u8               dcb_family;
 	__u8               cmd;
@@ -146,6 +204,7 @@ struct dcbmsg {
  * @DCB_CMD_SDCBX: set DCBX engine configuration
  * @DCB_CMD_GFEATCFG: get DCBX features flags
  * @DCB_CMD_SFEATCFG: set DCBX features negotiation flags
+ * @DCB_CMD_CEE_GET: get CEE aggregated configuration
  */
 enum dcbnl_commands {
 	DCB_CMD_UNDEFINED,
@@ -188,6 +247,8 @@ enum dcbnl_commands {
 	DCB_CMD_GFEATCFG,
 	DCB_CMD_SFEATCFG,
 
+	DCB_CMD_CEE_GET,
+
 	__DCB_CMD_ENUM_MAX,
 	DCB_CMD_MAX = __DCB_CMD_ENUM_MAX - 1,
 };
@@ -210,6 +271,7 @@ enum dcbnl_commands {
  * @DCB_ATTR_IEEE: IEEE 802.1Qaz supported attributes (NLA_NESTED)
  * @DCB_ATTR_DCBX: DCBX engine configuration in the device (NLA_U8)
  * @DCB_ATTR_FEATCFG: DCBX features flags (NLA_NESTED)
+ * @DCB_ATTR_CEE: CEE std supported attributes (NLA_NESTED)
  */
 enum dcbnl_attrs {
 	DCB_ATTR_UNDEFINED,
@@ -233,15 +295,32 @@ enum dcbnl_attrs {
 	DCB_ATTR_DCBX,
 	DCB_ATTR_FEATCFG,
 
+	/* CEE nested attributes */
+	DCB_ATTR_CEE,
+
 	__DCB_ATTR_ENUM_MAX,
 	DCB_ATTR_MAX = __DCB_ATTR_ENUM_MAX - 1,
 };
 
+/**
+ * enum ieee_attrs - IEEE 802.1Qaz get/set attributes
+ *
+ * @DCB_ATTR_IEEE_UNSPEC: unspecified
+ * @DCB_ATTR_IEEE_ETS: negotiated ETS configuration
+ * @DCB_ATTR_IEEE_PFC: negotiated PFC configuration
+ * @DCB_ATTR_IEEE_APP_TABLE: negotiated APP configuration
+ * @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only
+ * @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only
+ * @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only
+ */
 enum ieee_attrs {
 	DCB_ATTR_IEEE_UNSPEC,
 	DCB_ATTR_IEEE_ETS,
 	DCB_ATTR_IEEE_PFC,
 	DCB_ATTR_IEEE_APP_TABLE,
+	DCB_ATTR_IEEE_PEER_ETS,
+	DCB_ATTR_IEEE_PEER_PFC,
+	DCB_ATTR_IEEE_PEER_APP,
 	__DCB_ATTR_IEEE_MAX
 };
 #define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
@@ -254,6 +333,31 @@ enum ieee_attrs_app {
 #define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
 
 /**
+ * enum cee_attrs - CEE DCBX get attributes
+ *
+ * @DCB_ATTR_CEE_UNSPEC: unspecified
+ * @DCB_ATTR_CEE_PEER_PG: peer PG configuration - get only
+ * @DCB_ATTR_CEE_PEER_PFC: peer PFC configuration - get only
+ * @DCB_ATTR_CEE_PEER_APP: peer APP tlv - get only
+ */
+enum cee_attrs {
+	DCB_ATTR_CEE_UNSPEC,
+	DCB_ATTR_CEE_PEER_PG,
+	DCB_ATTR_CEE_PEER_PFC,
+	DCB_ATTR_CEE_PEER_APP_TABLE,
+	__DCB_ATTR_CEE_MAX
+};
+#define DCB_ATTR_CEE_MAX (__DCB_ATTR_CEE_MAX - 1)
+
+enum peer_app_attr {
+	DCB_ATTR_CEE_PEER_APP_UNSPEC,
+	DCB_ATTR_CEE_PEER_APP_INFO,
+	DCB_ATTR_CEE_PEER_APP,
+	__DCB_ATTR_CEE_PEER_APP_MAX
+};
+#define DCB_ATTR_CEE_PEER_APP_MAX (__DCB_ATTR_CEE_PEER_APP_MAX - 1)
+
+/**
  * enum dcbnl_pfc_attrs - DCB Priority Flow Control user priority nested attrs
  *
  * @DCB_PFC_UP_ATTR_UNDEFINED: unspecified attribute to catch errors
diff --git a/usr/io.c b/usr/io.c
index aa81941..fef6785 100644
--- a/usr/io.c
+++ b/usr/io.c
@@ -152,7 +152,7 @@ static void set_dcb_priority(struct iscsi_conn *conn, const char *devname)
 {
 	int pri_mask = 0;
 
-	pri_mask = get_dcb_app_pri_by_port(devname, ISCSI_DEFAULT_PORT);
+	pri_mask = get_dcb_app_pri_by_stream_port(devname, ISCSI_DEFAULT_PORT);
 	if (pri_mask < 0)
 		log_debug(2, "Getting priority for %s returned %d",
 				devname, pri_mask);

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list