From patchwork Sun Dec 16 16:06:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Domke X-Patchwork-Id: 1884841 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 50D40DFAC4 for ; Sun, 16 Dec 2012 16:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120Ab2LPQIJ (ORCPT ); Sun, 16 Dec 2012 11:08:09 -0500 Received: from mail01.nap.gsic.titech.ac.jp ([131.112.13.20]:53929 "HELO mail01.nap.gsic.titech.ac.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752992Ab2LPQII (ORCPT ); Sun, 16 Dec 2012 11:08:08 -0500 Received: from 131.112.13.36 by mail01.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(797:0:AUTH_RELAY) (envelope-from ); Mon, 17 Dec 2012 01:08:00 +0900 (JST) Received: from [131.112.13.20] (mail01.nap.gsic.titech.ac.jp) by drweb1.nap.gsic.titech.ac.jp (Dr.Web MailD 6.0.2.0) with SMTP id 012C88AD; Mon, 17 Dec 2012 01:08:00 Received: from 131.112.29.201 by mail01.nap.gsic.titech.ac.jp with Mail2000 ESMTP Server V6.00S(806:0:AUTH_LOGIN) (envelope-from ); Mon, 17 Dec 2012 01:07:58 +0900 (JST) From: Jens Domke To: Alex Netes Cc: linux-rdma@vger.kernel.org, Torsten Hoefler , Jens Domke Subject: [PATCH 1/1] OpenSM: DFSSSP does not find LIDs due to wrong byte order Date: Mon, 17 Dec 2012 01:06:53 +0900 Message-Id: <1355674013-3779-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: path_sl(...) arguments for slid/dlid are 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 necessaryand DFSSSP returns the correct SL for tht request Signed-off-by: Jens Domke --- opensm/osm_ucast_dfsssp.c | 26 +++++++++++++------------- 1 files changed, 13 insertions(+), 13 deletions(-) diff --git a/opensm/osm_ucast_dfsssp.c b/opensm/osm_ucast_dfsssp.c index ffc317f..903966c 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)); @@ -1645,7 +1645,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 */