[openib-general] [PATCH] Yet more sysfs support

Roland Dreier roland at topspin.com
Mon Sep 6 15:53:49 PDT 2004


By the way, since /sys/class/infiniband/mthca0/ports/1/cap_mask just
contains a hex number (such as '0x00500a68'), I wrote this quick
python script to decode that capabilities.  You can use it as:

    # python ~roland/bin/decode-cap mthca0 2
    Capabilities for mthca0 port 2:
            IsTrapSupported
            IsAutomaticMigrationSupported
            IsSLMappingSupported
            IsLEDInfoSupported
            IsSystemImageGUIDSupported
            IsVendorClassSupported
            IsCapabilityMaskNoticeSupported

- R.

#!/usr/bin/python

import sys

dev  = sys.argv[1]
port = sys.argv[2]

cap_name = {
    1:  'IsSM',
    2:  'IsNoticeSupported',
    3:  'IsTrapSupported',
    5:  'IsAutomaticMigrationSupported',
    6:  'IsSLMappingSupported',
    7:  'IsMKeyNVRAM',
    8:  'IsPKeyNVRAM',
    9:  'IsLEDInfoSupported',
    10: 'IsSMdisabled',
    11: 'IsSystemImageGUIDSupported',
    12: 'IsPKeySwitchExternalPortTrapSupported',
    16: 'IsCommunicationManagementSupported',
    17: 'IsSNMPTunnelingSupported',
    18: 'IsReinitSupported',
    19: 'IsDeviceManagementSupported',
    20: 'IsVendorClassSupported',
    21: 'IsDRNoticeSupported',
    22: 'IsCapabilityMaskNoticeSupported',
    23: 'IsBootManagementSupported'
    }

f = open('/sys/class/infiniband/' + dev + '/ports/' + port + '/cap_mask')
cap = int(f.read(), 0)

print 'Capabilities for ' + dev + ' port ' + port + ':'

for k in cap_name.keys():
    if cap & (1 << k) != 0:
        print '\t' + cap_name[k]



More information about the general mailing list