diff options
author | Roland Dreier <rolandd@cisco.com> | 2006-02-02 13:04:19 -0500 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-03-20 13:08:10 -0500 |
commit | 6dfc3901b04d1b79fa982d6de6d5af3b50c6cea8 (patch) | |
tree | f4918637c0d7c4b5c7fe4a4deb84e44ed3663dc6 /drivers/infiniband/hw | |
parent | c5bcbbb9fe00128d500c2f473d5ddc8d8c2c53a7 (diff) |
IB/mthca: Add modify_device method to set node description
Add a modify_device method to mthca, which implements setting the node
description. This makes the writable "node_desc" sysfs attribute work
for Mellanox HCAs.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_mad.c | 17 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 32 |
2 files changed, 48 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c index 1229c604c6e0..4ace6a392f41 100644 --- a/drivers/infiniband/hw/mthca/mthca_mad.c +++ b/drivers/infiniband/hw/mthca/mthca_mad.c | |||
@@ -109,6 +109,19 @@ static void smp_snoop(struct ib_device *ibdev, | |||
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | static void node_desc_override(struct ib_device *dev, | ||
113 | struct ib_mad *mad) | ||
114 | { | ||
115 | if ((mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED || | ||
116 | mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) && | ||
117 | mad->mad_hdr.method == IB_MGMT_METHOD_GET_RESP && | ||
118 | mad->mad_hdr.attr_id == IB_SMP_ATTR_NODE_DESC) { | ||
119 | mutex_lock(&to_mdev(dev)->cap_mask_mutex); | ||
120 | memcpy(((struct ib_smp *) mad)->data, dev->node_desc, 64); | ||
121 | mutex_unlock(&to_mdev(dev)->cap_mask_mutex); | ||
122 | } | ||
123 | } | ||
124 | |||
112 | static void forward_trap(struct mthca_dev *dev, | 125 | static void forward_trap(struct mthca_dev *dev, |
113 | u8 port_num, | 126 | u8 port_num, |
114 | struct ib_mad *mad) | 127 | struct ib_mad *mad) |
@@ -207,8 +220,10 @@ int mthca_process_mad(struct ib_device *ibdev, | |||
207 | return IB_MAD_RESULT_FAILURE; | 220 | return IB_MAD_RESULT_FAILURE; |
208 | } | 221 | } |
209 | 222 | ||
210 | if (!out_mad->mad_hdr.status) | 223 | if (!out_mad->mad_hdr.status) { |
211 | smp_snoop(ibdev, port_num, in_mad); | 224 | smp_snoop(ibdev, port_num, in_mad); |
225 | node_desc_override(ibdev, out_mad); | ||
226 | } | ||
212 | 227 | ||
213 | /* set return bit in status of directed route responses */ | 228 | /* set return bit in status of directed route responses */ |
214 | if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) | 229 | if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE) |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 76321f0ef019..1fa1b55ffffe 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -176,6 +176,23 @@ static int mthca_query_port(struct ib_device *ibdev, | |||
176 | return err; | 176 | return err; |
177 | } | 177 | } |
178 | 178 | ||
179 | static int mthca_modify_device(struct ib_device *ibdev, | ||
180 | int mask, | ||
181 | struct ib_device_modify *props) | ||
182 | { | ||
183 | if (mask & ~IB_DEVICE_MODIFY_NODE_DESC) | ||
184 | return -EOPNOTSUPP; | ||
185 | |||
186 | if (mask & IB_DEVICE_MODIFY_NODE_DESC) { | ||
187 | if (mutex_lock_interruptible(&to_mdev(ibdev)->cap_mask_mutex)) | ||
188 | return -ERESTARTSYS; | ||
189 | memcpy(ibdev->node_desc, props->node_desc, 64); | ||
190 | mutex_unlock(&to_mdev(ibdev)->cap_mask_mutex); | ||
191 | } | ||
192 | |||
193 | return 0; | ||
194 | } | ||
195 | |||
179 | static int mthca_modify_port(struct ib_device *ibdev, | 196 | static int mthca_modify_port(struct ib_device *ibdev, |
180 | u8 port, int port_modify_mask, | 197 | u8 port, int port_modify_mask, |
181 | struct ib_port_modify *props) | 198 | struct ib_port_modify *props) |
@@ -1187,6 +1204,20 @@ static int mthca_init_node_data(struct mthca_dev *dev) | |||
1187 | goto out; | 1204 | goto out; |
1188 | 1205 | ||
1189 | init_query_mad(in_mad); | 1206 | init_query_mad(in_mad); |
1207 | in_mad->attr_id = IB_SMP_ATTR_NODE_DESC; | ||
1208 | |||
1209 | err = mthca_MAD_IFC(dev, 1, 1, | ||
1210 | 1, NULL, NULL, in_mad, out_mad, | ||
1211 | &status); | ||
1212 | if (err) | ||
1213 | goto out; | ||
1214 | if (status) { | ||
1215 | err = -EINVAL; | ||
1216 | goto out; | ||
1217 | } | ||
1218 | |||
1219 | memcpy(dev->ib_dev.node_desc, out_mad->data, 64); | ||
1220 | |||
1190 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; | 1221 | in_mad->attr_id = IB_SMP_ATTR_NODE_INFO; |
1191 | 1222 | ||
1192 | err = mthca_MAD_IFC(dev, 1, 1, | 1223 | err = mthca_MAD_IFC(dev, 1, 1, |
@@ -1246,6 +1277,7 @@ int mthca_register_device(struct mthca_dev *dev) | |||
1246 | dev->ib_dev.class_dev.dev = &dev->pdev->dev; | 1277 | dev->ib_dev.class_dev.dev = &dev->pdev->dev; |
1247 | dev->ib_dev.query_device = mthca_query_device; | 1278 | dev->ib_dev.query_device = mthca_query_device; |
1248 | dev->ib_dev.query_port = mthca_query_port; | 1279 | dev->ib_dev.query_port = mthca_query_port; |
1280 | dev->ib_dev.modify_device = mthca_modify_device; | ||
1249 | dev->ib_dev.modify_port = mthca_modify_port; | 1281 | dev->ib_dev.modify_port = mthca_modify_port; |
1250 | dev->ib_dev.query_pkey = mthca_query_pkey; | 1282 | dev->ib_dev.query_pkey = mthca_query_pkey; |
1251 | dev->ib_dev.query_gid = mthca_query_gid; | 1283 | dev->ib_dev.query_gid = mthca_query_gid; |