From patchwork Mon Jul 30 07:57:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Netes X-Patchwork-Id: 1253531 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 01BA1DF24C for ; Mon, 30 Jul 2012 07:57:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753715Ab2G3H5t (ORCPT ); Mon, 30 Jul 2012 03:57:49 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:47018 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297Ab2G3H5s (ORCPT ); Mon, 30 Jul 2012 03:57:48 -0400 Received: by qcro28 with SMTP id o28so2764471qcr.19 for ; Mon, 30 Jul 2012 00:57:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent:x-gm-message-state; bh=lA2JWBCwTBApj2WYaKxMrlWpE/IYhmXADrGxCAMKFXM=; b=bHhoJaKpo0M9plCz0qPRBZVlWM+VBqZheeKC2wkbns5e2NlbKrDlt+xv4li4haxAZw EdMsXuVO/1LXjxlm35HJGnI6xyQUU8HmXLlDmj3SseaQ4HawFjhjaJ/oLsRYc7Z2siGQ 7yC2Or0tm0NeqBHACdvNdB4mQqYTjB18w3a4OZZpPU4REqr3Hi0Ak2CwAHI1n5RxtznN VTIDCzo9LzsRwc2qhgLdY8i0VCWNNWCpfQP8LH6ibnjuRSCumK/nHqgzo/9+ITgVNF26 I0IJOszQqqU1VqFeDTEXCiQ9RXV0Wf+YTxSCXvUk6gz6jtU1MAcQ5gV79aFNqSJDH+6e txpQ== Received: by 10.229.137.20 with SMTP id u20mr5202555qct.84.1343635067923; Mon, 30 Jul 2012 00:57:47 -0700 (PDT) Received: from localhost ([193.47.165.251]) by mx.google.com with ESMTPS id gw6sm4319880qab.21.2012.07.30.00.57.46 (version=SSLv3 cipher=OTHER); Mon, 30 Jul 2012 00:57:47 -0700 (PDT) Date: Mon, 30 Jul 2012 10:57:44 +0300 From: Alex Netes To: linux-rdma@vger.kernel.org, Hal Rosenstock Subject: [PATCH] opensm: Move per_mod_log_tbl array from subn to log structure Message-ID: <20120730075744.GK2590@calypso> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQl1RSFMgIcXRljwZbEgbh6/3oSZw59pHDqIP7WgcTNA9FFL+wuBpPgH/T8coAXEJFWmeJaU Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Having per_mod_log_tbl as part of subn structure is problematic because it means that subn structure should be part of libopensm which is highly undesired, so moving per_mod_log_tbl array from subn to log structure breaks that coupling. Signed-off-by: Alex Netes Signed-off-by: Hal Rosenstock --- include/opensm/osm_log.h | 65 +++++++++++++++++++++++++++++++++++++-------- include/opensm/osm_subnet.h | 9 ------- opensm/libopensm.map | 2 ++ opensm/osm_log.c | 21 ++++++++++----- opensm/osm_opensm.c | 1 - opensm/osm_subnet.c | 4 +-- 6 files changed, 73 insertions(+), 29 deletions(-) diff --git a/include/opensm/osm_log.h b/include/opensm/osm_log.h index 535d35e..3247296 100644 --- a/include/opensm/osm_log.h +++ b/include/opensm/osm_log.h @@ -48,7 +48,6 @@ #endif #include #include -#include #include #include @@ -99,10 +98,7 @@ BEGIN_C_DECLS * AUTHOR * *********/ -#ifndef OSM_LOG_LEVEL_T_DEFINED -#define OSM_LOG_LEVEL_T_DEFINED typedef uint8_t osm_log_level_t; -#endif #define OSM_LOG_NONE 0x00 #define OSM_LOG_ERROR 0x01 @@ -139,7 +135,7 @@ typedef struct osm_log { boolean_t daemon; char *log_file_name; char *log_prefix; - osm_subn_t *p_subn; + osm_log_level_t per_mod_log_tbl[256]; } osm_log_t; /*********/ @@ -156,12 +152,12 @@ typedef struct osm_log { * * SYNOPSIS */ -osm_log_level_t osm_get_log_per_module(IN osm_subn_t * subn, +osm_log_level_t osm_get_log_per_module(IN osm_log_t * p_log, IN const int file_id); /* * PARAMETERS - * subn - * [in] Pointer to an osm_subn_t object + * p_log + * [in] Pointer to a Log object to construct. * * file_id * [in] File ID for module @@ -170,6 +166,55 @@ osm_log_level_t osm_get_log_per_module(IN osm_subn_t * subn, * The log level from the per module logging structure for this file ID. *********/ +/****f* OpenSM: Log/osm_set_log_per_module + * NAME + * osm_set_log_per_module + * + * DESCRIPTION + * This sets log level for the given file ID in the per module log table. + * NOTE: this code is not thread safe. Need to grab the lock before + * calling it. + * + * SYNOPSIS + */ +void osm_set_log_per_module(IN osm_log_t * p_log, IN const int file_id, + IN osm_log_level_t level); +/* + * PARAMETERS + * p_log + * [in] Pointer to a Log object to construct. + * + * file_id + * [in] File ID for module + * + * level + * [in] Log level of the module + * + * RETURN VALUES + * This function does not return a value. + *********/ + +/****f* OpenSM: Log/osm_reset_log_per_module + * NAME + * osm_reset_log_per_module + * + * DESCRIPTION + * This resets log level for the entire per module log table. + * NOTE: this code is not thread safe. Need to grab the lock before + * calling it. + * + * SYNOPSIS + */ +void osm_reset_log_per_module(IN osm_log_t * p_log); +/* + * PARAMETERS + * p_log + * [in] Pointer to a Log object to construct. + * + * RETURN VALUES + * This function does not return a value. + *********/ + /****f* OpenSM: Log/osm_log_construct * NAME * osm_log_construct @@ -432,9 +477,7 @@ static inline boolean_t osm_log_is_active_v2(IN const osm_log_t * p_log, { if ((p_log->level & level) != 0) return 1; - if (!p_log->p_subn) - return 0; - if ((level & p_log->p_subn->per_mod_log_tbl[file_id])) + if ((level & p_log->per_mod_log_tbl[file_id])) return 1; return 0; } diff --git a/include/opensm/osm_subnet.h b/include/opensm/osm_subnet.h index 683204b..7f3d6e9 100644 --- a/include/opensm/osm_subnet.h +++ b/include/opensm/osm_subnet.h @@ -74,11 +74,6 @@ BEGIN_C_DECLS #define OSM_PARTITION_ENFORCE_OUT "out" #define OSM_PARTITION_ENFORCE_OFF "off" -#ifndef OSM_LOG_LEVEL_T_DEFINED -#define OSM_LOG_LEVEL_T_DEFINED -typedef uint8_t osm_log_level_t; -#endif - typedef enum _osm_partition_enforce_type_enum { OSM_PARTITION_ENFORCE_TYPE_BOTH, OSM_PARTITION_ENFORCE_TYPE_IN, @@ -604,7 +599,6 @@ typedef struct osm_subn { unsigned need_update; cl_fmap_t mgrp_mgid_tbl; void *mboxes[IB_LID_MCAST_END_HO - IB_LID_MCAST_START_HO + 1]; - osm_log_level_t per_mod_log_tbl[256]; } osm_subn_t; /* * FIELDS @@ -749,9 +743,6 @@ typedef struct osm_subn { * Array of pointers to all Multicast MLID box objects in the * subnet. Indexed by MLID offset from base MLID. * -* per_mod_log_tbl -* Array of log levels based on per module logging file ID. -* * SEE ALSO * Subnet object *********/ diff --git a/opensm/libopensm.map b/opensm/libopensm.map index 1735488..e75d424 100644 --- a/opensm/libopensm.map +++ b/opensm/libopensm.map @@ -92,5 +92,7 @@ OPENSM_1.5 { osm_log_msg_box_v2; osm_log_is_active_v2; osm_get_log_per_module; + osm_set_log_per_module; + osm_reset_log_per_module; local: *; }; diff --git a/opensm/osm_log.c b/opensm/osm_log.c index 94f0d03..2b7efe6 100644 --- a/opensm/osm_log.c +++ b/opensm/osm_log.c @@ -239,9 +239,7 @@ void osm_log_v2(IN osm_log_t * p_log, IN osm_log_level_t verbosity, /* If this is a call to syslog - always print it */ if (!(verbosity & p_log->level)) { - if (!p_log->p_subn) - return; - if (!(verbosity & p_log->p_subn->per_mod_log_tbl[file_id])) + if (!(verbosity & p_log->per_mod_log_tbl[file_id])) return; } @@ -472,7 +470,7 @@ ib_api_status_t osm_log_init_v2(IN osm_log_t * p_log, IN boolean_t flush, p_log->max_size = max_size << 20; /* convert size in MB to bytes */ p_log->accum_log_file = accum_log_file; p_log->log_file_name = (char *)log_file; - p_log->p_subn = NULL; + memset(p_log->per_mod_log_tbl, 0, sizeof(p_log->per_mod_log_tbl)); openlog("OpenSM", LOG_CONS | LOG_PID, LOG_USER); @@ -498,8 +496,19 @@ ib_api_status_t osm_log_init(IN osm_log_t * p_log, IN boolean_t flush, accum_log_file); } -osm_log_level_t osm_get_log_per_module(IN osm_subn_t * subn, +osm_log_level_t osm_get_log_per_module(IN osm_log_t * p_log, IN const int file_id) { - return subn->per_mod_log_tbl[file_id]; + return p_log->per_mod_log_tbl[file_id]; +} + +void osm_set_log_per_module(IN osm_log_t * p_log, IN const int file_id, + IN osm_log_level_t level) +{ + p_log->per_mod_log_tbl[file_id] = level; +} + +void osm_reset_log_per_module(IN osm_log_t * p_log) +{ + memset(p_log->per_mod_log_tbl, 0, sizeof(p_log->per_mod_log_tbl)); } diff --git a/opensm/osm_opensm.c b/opensm/osm_opensm.c index 429108a..817d111 100644 --- a/opensm/osm_opensm.c +++ b/opensm/osm_opensm.c @@ -375,7 +375,6 @@ ib_api_status_t osm_opensm_init(IN osm_opensm_t * p_osm, if (status != IB_SUCCESS) return status; p_osm->log.log_prefix = p_opt->log_prefix; - p_osm->log.p_subn = &p_osm->subn; /* If there is a log level defined - add the OSM_VERSION to it */ osm_log_v2(&p_osm->log, diff --git a/opensm/osm_subnet.c b/opensm/osm_subnet.c index ccaa47c..c8c96d1 100644 --- a/opensm/osm_subnet.c +++ b/opensm/osm_subnet.c @@ -1201,7 +1201,7 @@ static ib_api_status_t insert_per_module_debug(IN osm_subn_t * p_subn, "Module name %s not found\n", mod_name); return IB_ERROR; } - p_subn->per_mod_log_tbl[index] = level; + osm_set_log_per_module(&p_subn->p_osm->log, index, level); return IB_SUCCESS; } @@ -1213,7 +1213,7 @@ static ib_api_status_t parse_per_mod_logging_file(IN osm_subn_t * p_subn) int line = 0; int errors = 0; - memset(p_subn->per_mod_log_tbl, 0, sizeof(p_subn->per_mod_log_tbl)); + osm_reset_log_per_module(log); fp = fopen(p_subn->opt.per_module_logging_file, "r"); if (!fp) {