aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2007-08-03 13:45:18 -0400
committerRoland Dreier <rolandd@cisco.com>2007-08-03 13:45:18 -0400
commit5d7cbfd63136e4469a896acfadb33e19ed62f068 (patch)
tree1e15daafd7b22d1ac37f5469781d00339a9a0830 /drivers/infiniband
parent699924b1e1ea3c9307eb582b9cc386e4af88aaae (diff)
IB/srp: Wrap OUI checking for workarounds in helper functions
Wrap the checking for Mellanox and Topspin OUIs to decide whether to use a workaround into helper functions. This will make it cleaner to add a new OUI to check (as we need to do now that some targets with a Cisco OUI still need the Topspin workarounds). Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index f01ca182f226..fb6c5798daf3 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -75,16 +75,12 @@ module_param(topspin_workarounds, int, 0444);
75MODULE_PARM_DESC(topspin_workarounds, 75MODULE_PARM_DESC(topspin_workarounds,
76 "Enable workarounds for Topspin/Cisco SRP target bugs if != 0"); 76 "Enable workarounds for Topspin/Cisco SRP target bugs if != 0");
77 77
78static const u8 topspin_oui[3] = { 0x00, 0x05, 0xad };
79
80static int mellanox_workarounds = 1; 78static int mellanox_workarounds = 1;
81 79
82module_param(mellanox_workarounds, int, 0444); 80module_param(mellanox_workarounds, int, 0444);
83MODULE_PARM_DESC(mellanox_workarounds, 81MODULE_PARM_DESC(mellanox_workarounds,
84 "Enable workarounds for Mellanox SRP target bugs if != 0"); 82 "Enable workarounds for Mellanox SRP target bugs if != 0");
85 83
86static const u8 mellanox_oui[3] = { 0x00, 0x02, 0xc9 };
87
88static void srp_add_one(struct ib_device *device); 84static void srp_add_one(struct ib_device *device);
89static void srp_remove_one(struct ib_device *device); 85static void srp_remove_one(struct ib_device *device);
90static void srp_completion(struct ib_cq *cq, void *target_ptr); 86static void srp_completion(struct ib_cq *cq, void *target_ptr);
@@ -108,6 +104,22 @@ static const char *srp_target_info(struct Scsi_Host *host)
108 return host_to_target(host)->target_name; 104 return host_to_target(host)->target_name;
109} 105}
110 106
107static int srp_target_is_topspin(struct srp_target_port *target)
108{
109 static const u8 topspin_oui[3] = { 0x00, 0x05, 0xad };
110
111 return topspin_workarounds &&
112 !memcmp(&target->ioc_guid, topspin_oui, sizeof topspin_oui);
113}
114
115static int srp_target_is_mellanox(struct srp_target_port *target)
116{
117 static const u8 mellanox_oui[3] = { 0x00, 0x02, 0xc9 };
118
119 return mellanox_workarounds &&
120 !memcmp(&target->ioc_guid, mellanox_oui, sizeof mellanox_oui);
121}
122
111static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size, 123static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
112 gfp_t gfp_mask, 124 gfp_t gfp_mask,
113 enum dma_data_direction direction) 125 enum dma_data_direction direction)
@@ -360,7 +372,7 @@ static int srp_send_req(struct srp_target_port *target)
360 * zero out the first 8 bytes of our initiator port ID and set 372 * zero out the first 8 bytes of our initiator port ID and set
361 * the second 8 bytes to the local node GUID. 373 * the second 8 bytes to the local node GUID.
362 */ 374 */
363 if (topspin_workarounds && !memcmp(&target->ioc_guid, topspin_oui, 3)) { 375 if (srp_target_is_topspin(target)) {
364 printk(KERN_DEBUG PFX "Topspin/Cisco initiator port ID workaround " 376 printk(KERN_DEBUG PFX "Topspin/Cisco initiator port ID workaround "
365 "activated for target GUID %016llx\n", 377 "activated for target GUID %016llx\n",
366 (unsigned long long) be64_to_cpu(target->ioc_guid)); 378 (unsigned long long) be64_to_cpu(target->ioc_guid));
@@ -585,8 +597,8 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
585 if (!dev->fmr_pool) 597 if (!dev->fmr_pool)
586 return -ENODEV; 598 return -ENODEV;
587 599
588 if ((ib_sg_dma_address(ibdev, &scat[0]) & ~dev->fmr_page_mask) && 600 if (srp_target_is_mellanox(target) &&
589 mellanox_workarounds && !memcmp(&target->ioc_guid, mellanox_oui, 3)) 601 (ib_sg_dma_address(ibdev, &scat[0]) & ~dev->fmr_page_mask))
590 return -EINVAL; 602 return -EINVAL;
591 603
592 len = page_cnt = 0; 604 len = page_cnt = 0;
@@ -1087,8 +1099,7 @@ static void srp_cm_rej_handler(struct ib_cm_id *cm_id,
1087 break; 1099 break;
1088 1100
1089 case IB_CM_REJ_PORT_REDIRECT: 1101 case IB_CM_REJ_PORT_REDIRECT:
1090 if (topspin_workarounds && 1102 if (srp_target_is_topspin(target)) {
1091 !memcmp(&target->ioc_guid, topspin_oui, 3)) {
1092 /* 1103 /*
1093 * Topspin/Cisco SRP gateways incorrectly send 1104 * Topspin/Cisco SRP gateways incorrectly send
1094 * reject reason code 25 when they mean 24 1105 * reject reason code 25 when they mean 24