From patchwork Tue Jan 22 16:41:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Domke X-Patchwork-Id: 2019441 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CE8E83FD1A for ; Tue, 22 Jan 2013 16:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754718Ab3AVQr4 (ORCPT ); Tue, 22 Jan 2013 11:47:56 -0500 Received: from mail03.nap.gsic.titech.ac.jp ([131.112.13.22]:58653 "HELO mail03.nap.gsic.titech.ac.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754776Ab3AVQrx (ORCPT ); Tue, 22 Jan 2013 11:47:53 -0500 Received: from 131.112.13.36 by mail03.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(15868:0:AUTH_RELAY) (envelope-from ); Wed, 23 Jan 2013 01:41:55 +0900 (JST) Received: from [131.112.13.22] (mail03.nap.gsic.titech.ac.jp) by drweb1.nap.gsic.titech.ac.jp (Dr.Web MailD 6.0.2.0) with SMTP id 0167C4ED; Wed, 23 Jan 2013 01:41:55 Received: from 131.112.29.201 by mail03.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(15868:0:AUTH_LOGIN) (envelope-from ); Wed, 23 Jan 2013 01:41:55 +0900 (JST) From: Jens Domke To: linux-rdma@vger.kernel.org Cc: Alex Netes , Torsten Hoefler , Jens Domke Subject: [PATCH 09/10] OpenSM: DFSSSP does not find LIDs due to wrong byte order (v2) Date: Wed, 23 Jan 2013 01:41:47 +0900 Message-Id: <1358872907-17075-1-git-send-email-domke.j.aa@m.titech.ac.jp> X-Mailer: git-send-email 1.7.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Problem: argument list for external calls of path_sl(...) haas been changed at some point in the past; path_sl(...) arguments for slid/dlid are now in network byte order; internal storage of lids is host byte order; this mismatch results in a return value of 'hint_for_default_sl' of DFSSSP's get_dfsssp_sl function for every request Fix: lids will be stored in network byte order, so that a conversion is not necessary and DFSSSP returns the correct SL for that request This is version 2 of the original patch, because I forgot to change some internal calls. Please use this patch, instead of the patch from December 17. Signed-off-by: Jens Domke --- opensm/osm_ucast_dfsssp.c | 38 +++++++++++++++++++++----------------- 1 files changed, 21 insertions(+), 17 deletions(-) diff --git a/opensm/osm_ucast_dfsssp.c b/opensm/osm_ucast_dfsssp.c index 32bc8f1..c8a1007 100644 --- a/opensm/osm_ucast_dfsssp.c +++ b/opensm/osm_ucast_dfsssp.c @@ -339,7 +339,7 @@ static void heap_free(binary_heap_t * heap) /* compare function of two lids for stdlib qsort */ static int cmp_lids(const void *l1, const void *l2) { - uint16_t lid1 = *((uint16_t *) l1), lid2 = *((uint16_t *) l2); + ib_net16_t lid1 = *((ib_net16_t *) l1), lid2 = *((ib_net16_t *) l2); if (lid1 < lid2) return -1; @@ -352,19 +352,19 @@ static int cmp_lids(const void *l1, const void *l2) /* use stdlib to sort the lid array */ static inline void vltable_sort_lids(vltable_t * vltable) { - qsort(vltable->lids, vltable->num_lids, sizeof(uint16_t), cmp_lids); + qsort(vltable->lids, vltable->num_lids, sizeof(ib_net16_t), cmp_lids); } /* use stdlib to get index of key in lid array; return -1 if lid isn't found in lids array */ -static inline int64_t vltable_get_lidindex(uint16_t * key, vltable_t * vltable) +static inline int64_t vltable_get_lidindex(ib_net16_t * key, vltable_t * vltable) { - uint16_t *found_lid = NULL; + ib_net16_t *found_lid = NULL; found_lid = - (uint16_t *) bsearch(key, vltable->lids, vltable->num_lids, - sizeof(uint16_t), cmp_lids); + (ib_net16_t *) bsearch(key, vltable->lids, vltable->num_lids, + sizeof(ib_net16_t), cmp_lids); if (found_lid) return found_lid - vltable->lids; else @@ -374,7 +374,7 @@ static inline int64_t vltable_get_lidindex(uint16_t * key, vltable_t * vltable) /* get virtual lane from src lid X dest lid kombination; return -1 for invalid lids */ -static int32_t vltable_get_vl(vltable_t * vltable, uint16_t slid, uint16_t dlid) +static int32_t vltable_get_vl(vltable_t * vltable, ib_net16_t slid, ib_net16_t dlid) { int64_t ind1 = vltable_get_lidindex(&slid, vltable); int64_t ind2 = vltable_get_lidindex(&dlid, vltable); @@ -387,8 +387,8 @@ static int32_t vltable_get_vl(vltable_t * vltable, uint16_t slid, uint16_t dlid) } /* set a virtual lane in the matrix */ -static inline void vltable_insert(vltable_t * vltable, uint16_t slid, - uint16_t dlid, uint8_t vl) +static inline void vltable_insert(vltable_t * vltable, ib_net16_t slid, + ib_net16_t dlid, uint8_t vl) { int64_t ind1 = vltable_get_lidindex(&slid, vltable); int64_t ind2 = vltable_get_lidindex(&dlid, vltable); @@ -436,8 +436,8 @@ static void vltable_print(osm_ucast_mgr_t * p_mgr, vltable_t * vltable) OSM_LOG(p_mgr->p_log, OSM_LOG_DEBUG, " route from src_lid=%" PRIu16 " to dest_lid=%" PRIu16 " on vl=%" PRIu8 - "\n", vltable->lids[ind1], - vltable->lids[ind2], + "\n", cl_ntoh16(vltable->lids[ind1]), + cl_ntoh16(vltable->lids[ind2]), vltable->vls[ind1 + ind2 * vltable->num_lids]); } @@ -464,7 +464,7 @@ static int vltable_alloc(vltable_t ** vltable, uint64_t size) if (!(*vltable)) goto ERROR; (*vltable)->num_lids = size; - (*vltable)->lids = (uint16_t *) malloc(size * sizeof(uint16_t)); + (*vltable)->lids = (ib_net16_t *) malloc(size * sizeof(ib_net16_t)); if (!((*vltable)->lids)) goto ERROR; (*vltable)->vls = (uint8_t *) malloc(size * size * sizeof(uint8_t)); @@ -1704,7 +1704,7 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) osm_port_get_lid_range_ho(dest_port, &min_lid_ho, &max_lid_ho); for (dlid = min_lid_ho; dlid <= max_lid_ho; dlid++, i++) - srcdest2vl_table->lids[i] = dlid; + srcdest2vl_table->lids[i] = cl_hton16(dlid); } } /* sort lids */ @@ -1761,7 +1761,8 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) /* add the kombination / coresponding virtual lane to the VL table */ vltable_insert (srcdest2vl_table, - slid, dlid, + cl_hton16(slid), + cl_hton16(dlid), test_vl); paths_per_vl[test_vl]++; @@ -1811,7 +1812,8 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) if (test_vl != (uint8_t) vltable_get_vl(srcdest2vl_table, - slid, dlid)) + cl_hton16(slid), + cl_hton16(dlid))) continue; src_port = @@ -1853,8 +1855,10 @@ static int dfsssp_remove_deadlocks(dfsssp_context_t * dfsssp_ctx) "ERR AD14: cannot allocate memory for cdg node or link in update_channel_dep_graph(...)\n"); goto ERROR; } - vltable_insert(srcdest2vl_table, slid, - dlid, test_vl + 1); + vltable_insert(srcdest2vl_table, + cl_hton16(slid), + cl_hton16(dlid), + test_vl + 1); } if (weakest_link->num_pairs)