ib/mlx4: Add extended port capabilities support
PATCH 3/5 ib/mlx4: Add extended port capabilities support
An Extended Port Info packet is sent to each hw port during HCA init and if returns without error it is assumed the port supports extended port capabilities.
--- drivers/net/mlx4/main.c | 10 ++++++++++ drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/port.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/mlx4/device.h | 7 +++++++ 4 files changed, 59 insertions(+)
drivers/net/mlx4/main.c +10 -0
@@ -881,6 +881,7 @@ static int mlx4_setup_hca(struct mlx4_destruct mlx4_priv *priv =mlx4_priv (dev);int err;int port; +u64 ext_port_default_caps;__be32 ib_port_default_caps; err =mlx4_init_uar_table (dev);
@@ -998,6 +999,15 @@ static int mlx4_setup_hca(struct mlx4_de"ib capabilities (%d). Continuing with " "caps = 0\n", port, err); dev->caps.ib_port_def_cap[port] = ib_port_default_caps; + + ext_port_default_caps =0 ; + err =mlx4_get_ext_port_caps (dev, port, &ext_port_default_caps); +if (err) +mlx4_warn (dev,"failed to get port %d extended " +"port capabilities support (%d). Assuming " +"not supported\n" , port, err); + dev->caps.ext_port_cap[port] = ext_port_default_caps; + err =mlx4_SET_PORT (dev, port);if (err) { mlx4_err(dev, "Failed to set port %d, aborting\n",
drivers/net/mlx4/mlx4.h +1 -0
@@ -450,6 +450,7 @@ void mlx4_init_vlan_table(struct mlx4_deint mlx4_SET_PORT (struct mlx4_dev *dev,u8 port);int mlx4_get_port_ib_caps (struct mlx4_dev *dev,u8 port,__be32 *caps); +int mlx4_get_ext_port_caps (struct mlx4_dev *dev,u8 port,u64 *get_ext_caps);int mlx4_qp_detach_common (struct mlx4_dev *dev,struct mlx4_qp *qp,u8 gid[16 ],enum mlx4_protocol prot,enum mlx4_steer_type steer);
drivers/net/mlx4/port.c +41 -0
47 lines not on this page · raw message
include/linux/mlx4/device.h +7 -0
@@ -82,6 +82,12 @@ enum {MLX4_DEV_CAP_FLAG_COUNTERS =1LL <<48 }; +#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) + +enum { +MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO =1 <<0 +}; +enum {MLX4_BMME_FLAG_LOCAL_INV =1 <<6 ,MLX4_BMME_FLAG_REMOTE_INV =1 <<7 ,
@@ -276,6 +282,7 @@ struct mlx4_caps {u32 port_mask;enum mlx4_port_type possible_type[MLX4_MAX_PORTS +1 ];u32 max_counters; +u64 ext_port_cap[MLX4_MAX_PORTS +1 ]; };struct mlx4_buf_list {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 201110031755.41883.marcela-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org
This seems a bit obfuscated: we add a u64 ext_port_cap for each port, and then have a special setup function that just ORs in a single bit to that value (done by passing in a pointer).
Is there any reason mlx4_get_ext_port_caps() couldn't be more like mlx4_check_ext_port_caps(), and have that function set MLX4_FLAG_EXTENDED_PORT_INFO? Is it possible that
only some ports on the same HCA handle the extended port info query?
If so is there some reason this one bit needs a u64 to hold it?
Quoted 124 lines · Marcel Apfelbaum
An Extended Port Info packet is sent to each hw port during HCA init and if returns without error it is assumed the port supports extended port capabilities.
Signed-off-by Marcel Apfelbaum <[email protected]>---
drivers/net/mlx4/main.c | 10 ++++++++++ drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/port.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/mlx4/device.h | 7 +++++++ 4 files changed, 59 insertions(+)drivers/net/mlx4/main.c +1
-0@@ -881,6 +881,7 @@ static int mlx4_setup_hca(struct mlx4_de struct mlx4_priv *priv = mlx4_priv(dev); int err; int port; + u64 ext_port_default_caps; __be32 ib_port_default_caps; err = mlx4_init_uar_table(dev);@@ -998,6 +999,15 @@ static int mlx4_setup_hca(struct mlx4_de"ib capabilities (%d). Continuing with " "caps = 0\n", port, err); dev->caps.ib_port_def_cap[port] =
ib_port_default_caps;drivers/net/mlx4/main.c +9
-0+ + ext_port_default_caps = 0; + err = mlx4_get_ext_port_caps(dev, port, &ext_port_default_caps); + if (err) + mlx4_warn(dev, "failed to get port %d extended " + "port capabilities support (%d). Assuming " + "not supported\n", port, err); + dev->caps.ext_port_cap[port] = ext_port_default_caps; +err =
mlx4_SET_PORT(dev, port);
if (err) {
mlx4_err(dev, "Failed to set port %d, aborting\n",drivers/net/mlx4/mlx4.h +1
-0@@ -450,6 +450,7 @@ void mlx4_init_vlan_table(struct mlx4_de int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port); int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps); +int mlx4_get_ext_port_caps (struct mlx4_dev *dev,u8 port,u64 *get_ext_caps); int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], enum mlx4_protocol prot, enum mlx4_steer_type steer);drivers/net/mlx4/port.c +41
-0@@ -464,6 +464,47 @@ int mlx4_get_port_ib_caps(struct mlx4_de return err; } +int mlx4_get_ext_port_caps (struct mlx4_dev *dev,u8 port,u64 *get_ext_caps) +{ + struct mlx4_cmd_mailbox *inmailbox, *outmailbox; + u8 *inbuf, *outbuf; + int err, packet_error; + + inmailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(inmailbox)) + return PTR_ERR(inmailbox); + + outmailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(outmailbox)) { + mlx4_free_cmd_mailbox(dev, inmailbox); + return PTR_ERR(outmailbox); + } + + inbuf = inmailbox->buf; + outbuf = outmailbox->buf; + memset(inbuf, 0, 256); + memset(outbuf, 0, 256); + inbuf[0] = 1; + inbuf[1] = 1; + inbuf[2] = 1; + inbuf[3] = 1; + + *(__be16 *) (&inbuf[16]) = MLX4_ATTR_EXTENDED_PORT_INFO; + *(__be32 *) (&inbuf[20]) = cpu_to_be32(port); + + err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3, + MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C); + + packet_error = be16_to_cpu(*(__be16 *) (outbuf + 4)); + + if (!err && !packet_error) + *get_ext_caps |= MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO; + + mlx4_free_cmd_mailbox(dev, inmailbox); + mlx4_free_cmd_mailbox(dev, outmailbox); + return err; +} + int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port) { struct mlx4_cmd_mailbox *mailbox;include/linux/mlx4/device.h +0
-0@@ -82,6 +82,12 @@ enum {MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48 };
include/linux/mlx4/device.h +6
-0+#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) + +enum { + MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0 +}; +enum {
MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,include/linux/mlx4/device.h +1
-1@@ -276,6 +282,7 @@ struct mlx4_caps { u32 port_mask; enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1]; u32 max_counters; + u64 ext_port_cap[MLX4_MAX_PORTS + 1]; }; struct mlx4_buf_list { --
Quoted 4 lines
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): CAL1RGDUc=5=Xce9PXTFe3p55kZPnQKcBxRwRnkAwASKc9MFAVQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Hi Roland,
Thanks for the review.
The extended capabilities are indeed per port. It is possible that every port has its own extended capabilities.
The reason I used a 64bit field for a bit is to prepare a field for future extended capabilities.
In my opinion new capabilities will be appended to this field sooner or later and I want it to be ready.
It seems to me more elegant to prepare this field in advance, rather than append a new field for each such a feature.
What do you think?
Marcel
Quoted 135 lines · Roland Dreier
This seems a bit obfuscated: we add a u64
ext_port_capfor each port, and then have a special setup function that just ORs in a single bit to that value (done by passing in a pointer).Is there any reason
mlx4_get_ext_port_caps()couldn't be more likemlx4_check_ext_port_caps(), and have that function setMLX4_FLAG_EXTENDED_PORT_INFO? Is it possible that
only some ports on the same HCA handle the extended port info query?If so is there some reason this one bit needs a u64 to hold it?
Quoted 122 lines · Marcel Apfelbaum
An Extended Port Info packet is sent to each hw port during HCA init and if returns without error it is assumed the port supports extended port capabilities.
Signed-off-by Marcel Apfelbaum <[email protected]>---
drivers/net/mlx4/main.c | 10 ++++++++++ drivers/net/mlx4/mlx4.h | 1 + drivers/net/mlx4/port.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/mlx4/device.h | 7 +++++++ 4 files changed, 59 insertions(+)drivers/net/mlx4/main.c +1
-0@@ -881,6 +881,7 @@ static int mlx4_setup_hca(struct mlx4_de struct mlx4_priv *priv = mlx4_priv(dev); int err; int port; + u64 ext_port_default_caps; __be32 ib_port_default_caps; err = mlx4_init_uar_table(dev);@@ -998,6 +999,15 @@ static int mlx4_setup_hca(struct mlx4_de"ib capabilities (%d). Continuing with " "caps = 0\n", port, err); dev->caps.ib_port_def_cap[port] =
ib_port_default_caps;drivers/net/mlx4/main.c +9
-0+ + ext_port_default_caps = 0; + err = mlx4_get_ext_port_caps(dev, port, &ext_port_default_caps); + if (err) + mlx4_warn(dev, "failed to get port %d extended " + "port capabilities support (%d). Assuming " + "not supported\n", port, err); + dev->caps.ext_port_cap[port] = ext_port_default_caps; +err =
mlx4_SET_PORT(dev, port);
if (err) {
mlx4_err(dev, "Failed to set port %d, aborting\n",drivers/net/mlx4/mlx4.h +1
-0@@ -450,6 +450,7 @@ void mlx4_init_vlan_table(struct mlx4_de int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port); int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps); +int mlx4_get_ext_port_caps (struct mlx4_dev *dev,u8 port,u64 *get_ext_caps); int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], enum mlx4_protocol prot, enum mlx4_steer_type steer);drivers/net/mlx4/port.c +41
-0@@ -464,6 +464,47 @@ int mlx4_get_port_ib_caps(struct mlx4_de return err; } +int mlx4_get_ext_port_caps (struct mlx4_dev *dev,u8 port,u64 *get_ext_caps) +{ + struct mlx4_cmd_mailbox *inmailbox, *outmailbox; + u8 *inbuf, *outbuf; + int err, packet_error; + + inmailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(inmailbox)) + return PTR_ERR(inmailbox); + + outmailbox = mlx4_alloc_cmd_mailbox(dev); + if (IS_ERR(outmailbox)) { + mlx4_free_cmd_mailbox(dev, inmailbox); + return PTR_ERR(outmailbox); + } + + inbuf = inmailbox->buf; + outbuf = outmailbox->buf; + memset(inbuf, 0, 256); + memset(outbuf, 0, 256); + inbuf[0] = 1; + inbuf[1] = 1; + inbuf[2] = 1; + inbuf[3] = 1; + + *(__be16 *) (&inbuf[16]) = MLX4_ATTR_EXTENDED_PORT_INFO; + *(__be32 *) (&inbuf[20]) = cpu_to_be32(port); + + err = mlx4_cmd_box(dev, inmailbox->dma, outmailbox->dma, port, 3, + MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C); + + packet_error = be16_to_cpu(*(__be16 *) (outbuf + 4)); + + if (!err && !packet_error) + *get_ext_caps |= MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO; + + mlx4_free_cmd_mailbox(dev, inmailbox); + mlx4_free_cmd_mailbox(dev, outmailbox); + return err; +} + int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port) { struct mlx4_cmd_mailbox *mailbox;include/linux/mlx4/device.h +0
-0@@ -82,6 +82,12 @@ enum {MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48 };
include/linux/mlx4/device.h +6
-0+#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90) + +enum { + MLX_EXT_PORT_CAP_FLAG_EXTENDED_PORT_INFO = 1 << 0 +}; +enum {
MLX4_BMME_FLAG_LOCAL_INV = 1 << 6,
MLX4_BMME_FLAG_REMOTE_INV = 1 << 7,include/linux/mlx4/device.h +1
-0@@ -276,6 +282,7 @@ struct mlx4_caps { u32 port_mask; enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1]; u32 max_counters; + u64 ext_port_cap[MLX4_MAX_PORTS + 1]; };
Quoted 7 lines
Quoted 6 lines
include/linux/mlx4/device.h +0
-1struct mlx4_buf_list { --To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Roland Dreier
Is there any reason
mlx4_get_ext_port_caps()couldn't be more likemlx4_check_ext_port_caps(), and have that function setMLX4_FLAG_EXTENDED_PORT_INFO? Is it possible that
only some ports on the same HCA handle the extended port info query? If so is there some reason this one bit needs a u64 to hold it?
Roland,
I hope you saw Marcel's reply saying that yes, it could be that only some ports on the same HCA can handle this query, so this does need to be per port.
As for that "this" do you prefer this flag to be implemented now as "u8 ext_info" field of the port structure and turned into a bit which is part of 32/64 bits extended_info caps field later when the 2nd such cap pops out?
Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html