Hi Hal:
Thanks. Basically, I m using the following flow in my application:
status = opensm_init(&options, (osm_log_level_t) log_flags );
// Get some portID where you need to bind this SM
if ( guid == 0 && !(guid = get_port_guid(guid, &port_attr)))
{
printf("\n We can't proceed further without port_guid \n");
exit(0);
}
status = opensm_bind(&port_attr) ;
// The above function internally calls
// osmv_bind_sa(...) function of libvendor library.
Then, I m calling opensm_saquery()..this function prepares
the query request and calls
status = osmv_query_sa(openSMObject.h_bind, &req) ;
So, I believe, I m not playing with transaction ID here.
Thus, I m wondering what could have been happened with transaction ID
mismatched. I have attached my application code file along with this mail
for your kind reference. Please take a look.
I m also trying to figure out what initilization has been done by openSM
instance which is not happening through my normal application startup
time.
One thing, I have observed is as below which might help me to get your
comments:
1. I Start openSM instance in one terminal. It says Subnet is up and it is
Master.
2. On other terminal when I start my attached application, then openSM
terminal says I m processing the MAD ( osm_sa_mad_ctrl.c processing
function ).
It means that, my application acts as a client and openSM acting as a
server to serve the request. I would like to deattached this client and
server communication. This is my current goal.
If you could point to me what exactly I need to do for this then it would
be great help. If you could point me to the documentation then it would
also help me to understand the communication between the client and openSM
as a server.
Thanks and Regards,
- Takshak
> Hi Takshak,
>
> On Fri, 2006-02-24 at 08:09, Takshak C. wrote:
>> Hi Hal:
>>
>> Thanks for the information.
>>
>> I would like to confirm that, umad_send() and umad_recv calls goes out
>> of osm libraries.
>
> Not sure what you mean by this. The umad library of which those calls
> are a part of is underneath any OSM libraries that might be used.
>
>> I have written an application to get PATH_RECORDS using opensm libraries
>> similar to osmtest.
>> If I don't start openSM instance, then I don't get results rather I get
>> an error message as
>> below:
>> [ umad_receiver: ERR 5409: send completed with error (method=0x12
>> attr=0x35 trans_id=0x1) -- dropping ]
>
> That's saying that a matching receive was not seen (the response to the
> GetTable PathRecord request). The transaction ID looks funny to me for
> matching. Is this being set correctly ? (Not having the code it is hard
> for me to tell how things are initialized and what mode this is working
> in).
>
>> I have tried to go inside. Just after umad_send() call in
>> osm_vendor_ibumad.c ( osm_vendor_send() function ),
>> I called umad_recv() function call and tried to check the receive
>> length. And I am getting 24.
>>
>> Why this could have been happened ? return length = 24 means call has
>> not received path records.
>
> Because if it is getting a response, due to the transaction ID, I do not
> think it is considered a match. I can't be sure with the info provided.
>
>> But if I start openSM instance then I get proper result length.
>
> Sounds like your application may have an initialization issue that this
> fixes.
>
>> I would like to remove dependency of starting this openSM instance and
>> my application program
>> should run independently.
>
> This should be possible.
>
>> Could you please throw me some light on this. When I have called
>> umad_recv() it should not depend
>> on openSM instance I believe to received the things.
>
> Correct.
>
> -- Hal
>
>> Thanks & Regards.
>> - Takshak
>>
>>
>> Hal Rosenstock wrote:
>> > On Wed, 2006-02-22 at 08:09, Takshak C. wrote:
>> > > Thanks a lot Hal, for clearing my doubts.
>> > > I would like to redefine my problem based on your inputs.
>> > >
>> > > I am into a scenario, where vendor specific primary SM is running in
>> > > the subnet.
>> > > This running SM is different than openSM. I have loaded an openIB
>> > > stack on the host.
>> >
>> > OK. I understand your configuration.
>> >
>> > > Some of the sample examples from management/diags/src/ directory
>> like
>> > > smpquery
>> > > for nodeinfo etc works and gives result to me.
>> > >
>> > > Now, could it be possible for me to write a SA query and fetch the
>> > > path, service
>> > > or info records
>> >
>> > Info records ?
>> >
>> > > without starting openSM instance as I have already primary SM
>> > > running in the subnet. ?
>> >
>> > Yes; all you are (conceptually) talking about is a user SA client.
>> >
>> > > I believe, this question could be right and your answer would
>> > > help me.
>> > >
>> > > I do not want to start openSM because then synchronization between
>> > > primary SM
>> > > and openSM would bring other issues or difficulties.
>> >
>> > Understood. It was unclear whether you had an SM in your subnet.
>> >
>> > You should be able to link libopensm and the other management
>> libraries
>> > to an SA application which would do this (and not require OpenSM
>> > itself).
>> >
>> > > Could you please tell me, how should I go about it ? Waiting.
>> >
>> > I think I've already answered this.
>> >
>> > -- Hal
>> >
>> > > Regards.
>> > > - Takshak
>> > >
>> > >
>> > >
>> > > Hal Rosenstock wrote:
>> > > > On Wed, 2006-02-22 at 06:56, Takshak C. wrote:
>> > > >
>> > > > > Hal Rosenstock wrote:
>> > > > >
>> > > > > > > Please throw some light on this. Do you have any userspace
>> SA support for retrieving path, service record
>> > > > > > > information ?
>> > > > > > >
>> > > > > > >
>> > > > > >
>> > > > > > There have been discussions about userspace SA support but
>> nothing
>> > > > > > currently for OpenIB (gen2). Currently, you can get this by
>> using
>> > > > > >
>> > > > > >
>> > > > >
>> > > > > Could you please tell me, when userspace SA support will be
>> available
>> > > > > in openIB gen2.
>> > > > >
>> > > >
>> > > > I don't know but I'm not sure how much this helps you based on
>> your
>> > > > questions below.
>> > > >
>> > > >
>> > > > > > osm_vendor_ibumad_sa.c which supports most SA requests. It is
>> built as
>> > > > > > part of libosmvendor (part of the OpenSM build) but can be
>> used outside
>> > > > > > of OpenSM. It is used by osmtest if you want to look at some
>> use cases.
>> > > > > > It obtains PathRecords and ServiceRecords. That might be an
>> easier
>> > > > > > direction to go than trying to use the management libraries to
>> build the
>> > > > > > pieces of a userspace SA client you want.
>> > > > > >
>> > > > > > -- Hal
>> > > > > >
>> > > > > >
>> > > > >
>> > > > > See, to execute osmtest, I found that openSM instance must be
>> there.
>> > > > >
>> > > >
>> > > > Must be where ? What is your IB configuration ?
>> > > >
>> > > >
>> > > > > So, even if I use part
>> > > > > of libosmvendor library ( osm_vendor_ibumad_sa.c) functions, I
>> have to
>> > > > > start openSM
>> > > > > instance to execute the SA query successfully.
>> > > > >
>> > > >
>> > > > An SM is needed in the subnet and SA is part of that and answers
>> such
>> > > > queries.
>> > > >
>> > > >
>> > > > > Without starting openSM client, I m able to retrieve node
>> description,
>> > > > > node info, SM info,
>> > > > > port info by using management libraries libibumad and libibmad.
>> > > > >
>> > > >
>> > > > of the local node only (until the SM brings up the subnet).
>> > > >
>> > > >
>> > > > > What I want to achieve is, without talking with openSM instance,
>> my SA
>> > > > > query client
>> > > > > should go and get the required information.
>> > > > >
>> > > >
>> > > > Why ?
>> > > >
>> > > >
>> > > > > Is this possible ?.
>> > > > >
>> > > >
>> > > > No. What would you query for paths to if the subnet were not up ?
>> > > >
>> > > > -- Hal
>> > > >
>> > > >
>> > > > > Would like to know your inputs on this.
>> > > > >
>> > > > > Regards,
>> > > > > - Takshak
>> > > > >
>> > > > > > > Regards.
>> > > > > > > - Takshak
>> > > > > > >
>> > > > > > >
>> > > > > > > Hal Rosenstock wrote:
>> > > > > > >
>> > > > > > >
>> > > > > > >
>> > > > > > > > Hi,
>> > > > > > > >
>> > > > > > > > There are a couple of issues with the below.
>> > > > > > > >
>> > > > > > > > 1. SA MAD structure is missing the RMPP header. Once I saw
>> that I didn't check for further issues with the format.
>> > > > > > > >
>> > > > > > > > 2. I will assume your register call sets RMPP.
>> > > > > > > >
>> > > > > > > > 3. SA class version is 2.
>> > > > > > > >
>> > > > > > > > What SM are you using ? If you are using OpenSM, you can
>> turn on verbose and see if the packet is seen by the SM.
>> You could also enable madeye (in utils) to see if the
>> packet is sent (and if anything is received back).
>> > > > > > > >
>> > > > > > > > -- Hal
>> > > > > > > >
>> > > > > > > > ________________________________
>> > > > > > > >
>> > > > > > > > From: [EMAIL PROTECTED] on behalf of
>> Takshak C.
>> > > > > > > > Sent: Mon 2/6/2006 8:00 AM
>> > > > > > > > To: [email protected]
>> > > > > > > > Subject: [openib-general] Get Table Records for SA
>> Attribute ID ?
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > Hi,
>> > > > > > > >
>> > > > > > > > I m trying to get the table records for SA attribute ID in
>> following way.
>> > > > > > > > But, I m not getting a single record, could anyone comment
>> on the problem.
>> > > > > > > >
>> > > > > > > > 1. I have created saMadFormat structure described in the
>> specification as below:
>> > > > > > > >
>> > > > > > > > struct saMadFormat
>> > > > > > > > {
>> > > > > > > >
>> > > > > > > > uint8_t base_version ;
>> > > > > > > > uint8_t mgmt_class ;
>> > > > > > > > uint8_t class_version ;
>> > > > > > > > uint8_t sa_method ;
>> > > > > > > > uint16_t status ;
>> > > > > > > > uint16_t not_used ;
>> > > > > > > > uint64_t tid ;
>> > > > > > > > uint16_t attr_id ;
>> > > > > > > > uint16_t resv ;
>> > > > > > > > uint32_t attr_mod ;
>> > > > > > > > uint64_t sa_key;
>> > > > > > > > uint64_t sm_key ;
>> > > > > > > > uint32_t seg_num ;
>> > > > > > > > uint32_t payload_len ;
>> > > > > > > > uint8_t frag_flag ;
>> > > > > > > > uint8_t edit_mod ;
>> > > > > > > > uint16_t window ;
>> > > > > > > > uint32_t endRID ;
>> > > > > > > > uint64_t comp_mask ;
>> > > > > > > > uint8_t adminData[192] ;
>> > > > > > > > };
>> > > > > > > >
>> > > > > > > > 2. Then I have done all the basic operations like
>> umad_open, umad_register for the IB_SA_CLASS
>> > > > > > > > and umad_open_port etc successfully.
>> > > > > > > >
>> > > > > > > > 3. struct saMadFormat *saQuery = (struct
>> saMadFormat*)(umad_get_mad(umad));
>> > > > > > > > memset(saQuery, 0, sizeof(*saQuery));
>> > > > > > > >
>> > > > > > > > saQuery->base_version = 1;
>> > > > > > > > saQuery->mgmt_class = IB_SA_CLASS ;
>> > > > > > > > saQuery->class_version = 1 ;
>> > > > > > > > saQuery->sa_method = IB_MAD_METHOD_GET_TABLE ;
>> > > > > > > > saQuery->attr_id = IB_SA_ATTR_PATHRECORD ;
>> > > > > > > > saQuery->attr_mod = 0 ;
>> > > > > > > > saQuery->tid = htonll(drmad_tid++);
>> > > > > > > > saQuery->endRID = 0 ;
>> > > > > > > >
>> > > > > > > > umad_set_addr(umad, lid, 1, 0, IB_DEFAULT_QP1_QKEY);
>> > > > > > > > umad_set_grh(umad, 0);
>> > > > > > > > umad_set_pkey(umad, 0xFFFF);
>> > > > > > > >
>> > > > > > > > 4. length = IB_MAD_SIZE;
>> > > > > > > >
>> > > > > > > > if (umad_send(portid, mad_agent, umad, length,
>> timeout_ms, 0) < 0)
>> > > > > > > > IBPANIC("send failed");
>> > > > > > > >
>> > > > > > > > if (umad_recv(portid, umad, &length, -1) != mad_agent)
>> > > > > > > > IBPANIC("recv error: %s", drmad_status_str(saQuery));
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > if (!dump_char) {
>> > > > > > > > xdump(stdout, 0, saQuery->adminData, 192);
>> > > > > > > > return 0;
>> > > > > > > > }
>> > > > > > > >
>> > > > > > > > I m expecting that, I will get the resultant data in
>> saQuery->adminData.
>> > > > > > > > Is this correct ? If not then, how should I retrieve the
>> table records ?
>> > > > > > > > Any Idea ?
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > Thanks
>> > > > > > > > - Takshak
>> > > > > > > >
>> > > > > > > > _______________________________________________
>> > > > > > > > openib-general mailing list
>> > > > > > > > [email protected]
>> > > > > > > > http://openib.org/mailman/listinfo/openib-general
>> > > > > > > >
>> > > > > > > > To unsubscribe, please visit
>> http://openib.org/mailman/listinfo/openib-general
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > > > >
>> > > > > >
>> > > > > >
>> > > >
>> > > >
>> >
>>
>
>
#include <stdlib.h>
#include "osmtest.h"
#define POOL_MIN_ITEMS 64
#define MAX_LID 100
#define GUID_ARRAY_SIZE 64
#define OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC 1000
#define OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC 10
#define OSMT_DEFAULT_RETRY_COUNT 3
// Global object for querying SM information
static osmtest_t openSMObject ;
void opensm_set_default_options(osmtest_opt_t *opt)
{
opt->transaction_timeout = OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC;
opt->wait_time = OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC;
opt->retry_count = OSMT_DEFAULT_RETRY_COUNT;
opt->force_log_flush = FALSE;
opt->stress = 0;
opt->log_file = NULL;
opt->create = FALSE;
opt->mmode = 1;
opt->ignore_path_records = FALSE; /* Do path Records too. */
opt->flow = 0; /* run all validation tests */
//strcpy(optflow_name, "All Validations");
strcpy( opt->file_name, "osmtest.dat" );
}
/*
void osm_set_default_options( osm_subn_opt_t* const p_opt )
{
cl_memclr(p_opt, sizeof(osm_subn_opt_t));
p_opt->m_key = OSM_DEFAULT_M_KEY;
p_opt->sm_key = OSM_DEFAULT_SM_KEY;
p_opt->subnet_prefix = IB_DEFAULT_SUBNET_PREFIX;
p_opt->m_key_lease_period = 0;
p_opt->sweep_interval = OSM_DEFAULT_SWEEP_INTERVAL_SECS;
p_opt->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
p_opt->console = FALSE;
p_opt->transaction_timeout = OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
p_opt->max_msg_fifo_timeout = 50*OSM_DEFAULT_TRANS_TIMEOUT_MILLISEC;
p_opt->sm_priority = OSM_DEFAULT_SM_PRIORITY;
p_opt->lmc = OSM_DEFAULT_LMC;
p_opt->max_op_vls = OSM_DEFAULT_MAX_OP_VLS;
p_opt->reassign_lids = FALSE;
p_opt->reassign_lfts = TRUE;
p_opt->ignore_other_sm = FALSE;
p_opt->single_thread = FALSE;
p_opt->no_multicast_option = FALSE;
p_opt->disable_multicast = FALSE;
p_opt->force_log_flush = FALSE;
p_opt->subnet_timeout = OSM_DEFAULT_SUBNET_TIMEOUT;
p_opt->packet_life_time = OSM_DEFAULT_SWITCH_PACKET_LIFE;
p_opt->head_of_queue_lifetime = OSM_DEFAULT_HEAD_OF_QUEUE_LIFE;
p_opt->leaf_head_of_queue_lifetime =
OSM_DEFAULT_LEAF_HEAD_OF_QUEUE_LIFE;
p_opt->local_phy_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
p_opt->overrun_errors_threshold = OSM_DEFAULT_ERROR_THRESHOLD;
p_opt->sminfo_polling_timeout =
OSM_SM_DEFAULT_POLLING_TIMEOUT_MILLISECS;
p_opt->polling_retry_number = 4;
p_opt->force_heavy_sweep = FALSE;
p_opt->log_flags = 0;
p_opt->dump_files_dir = getenv("OSM_TMP_DIR");
if (!p_opt->dump_files_dir)
p_opt->dump_files_dir = OSM_DEFAULT_TMP_DIR;
p_opt->log_file = OSM_DEFAULT_LOG_FILE;
p_opt->accum_log_file = TRUE;
p_opt->port_profile_switch_nodes = FALSE;
p_opt->max_port_profile = 0xffffffff;
p_opt->pfn_ui_pre_lid_assign = NULL;
p_opt->ui_pre_lid_assign_ctx = NULL;
p_opt->pfn_ui_ucast_fdb_assign = NULL;
p_opt->ui_ucast_fdb_assign_ctx = NULL;
p_opt->pfn_ui_mcast_fdb_assign = NULL;
p_opt->ui_mcast_fdb_assign_ctx = NULL;
p_opt->sweep_on_trap = TRUE;
p_opt->testability_mode = OSM_TEST_MODE_NONE;
p_opt->updn_activate = FALSE;
p_opt->updn_guid_file = NULL;
p_opt->exit_on_fatal = TRUE;
}
*/
ib_net64_t get_port_guid( uint64_t port_guid, ib_port_attr_t *portAttr)
{
ib_api_status_t status ;
uint32_t num_ports = GUID_ARRAY_SIZE ;
ib_port_attr_t attr_array[GUID_ARRAY_SIZE] ;
int i ;
status = osm_vendor_get_all_port_attr( openSMObject.p_vendor,
attr_array, &num_ports);
if ( status != IB_SUCCESS )
{
printf("\n Couldn't find any port on this HCA ");
return(0);
}
if ( port_guid == 0 || num_ports == 1 )
{
printf("\n Using Default GUID 0x%" PRIx64 "\n",
cl_hton64(attr_array[0].port_guid));
cl_memcpy(portAttr,&attr_array[0],sizeof(*portAttr));
return ( attr_array[0].port_guid);
}
// If portGUID is not zero then
for ( i = 0 ; i < num_ports ; i ++ )
{
if ( attr_array[i].port_guid == port_guid )
{
cl_memcpy(portAttr,&attr_array[i],sizeof(*portAttr));
return port_guid ;
}
}
return 0;
}
void
subnet_construct( subnet_t * const p_subn )
{
cl_qmap_init( &p_subn->link_tbl );
cl_qmap_init( &p_subn->node_lid_tbl );
cl_qmap_init( &p_subn->node_guid_tbl );
cl_qmap_init( &p_subn->mgrp_mlid_tbl );
/* NO WAY TO HAVE UNIQUE PORT BY LID OR GUID */
/* cl_qmap_init( &p_subn->port_lid_tbl ); */
/* cl_qmap_init( &p_subn->port_guid_tbl ); */
/* port key is a lid and num pair */
cl_qmap_init( &p_subn->port_key_tbl );
cl_qmap_init( &p_subn->path_tbl );
}
ib_api_status_t
opensm_init(osmtest_opt_t *p_opt, osm_log_level_t log_flags)
{
ib_api_status_t status ;
cl_memclr(&openSMObject, sizeof( openSMObject) );
osm_log_construct( &openSMObject.log );
subnet_construct( &openSMObject.exp_subn );
status = osm_log_init(&openSMObject.log, p_opt->force_log_flush,
0x0001,
p_opt->log_file, TRUE);
if (status != IB_SUCCESS )
{
printf("\n Log Initialization has some problem \n");
exit(0);
}
osm_log_set_level(&openSMObject.log, log_flags);
openSMObject.opt = *p_opt ;
status = cl_qpool_init(&openSMObject.node_pool, POOL_MIN_ITEMS, 0,
POOL_MIN_ITEMS,
sizeof(node_t), NULL, NULL, NULL);
CL_ASSERT( status == CL_SUCCESS );
status = cl_qpool_init(&openSMObject.port_pool, POOL_MIN_ITEMS, 0,
POOL_MIN_ITEMS,
sizeof(port_t), NULL, NULL, NULL);
CL_ASSERT( status == CL_SUCCESS );
openSMObject.p_vendor = osm_vendor_new(&openSMObject.log,
p_opt->transaction_timeout);
if ( openSMObject.p_vendor == NULL )
{
status = IB_INSUFFICIENT_RESOURCES ;
return IB_ERROR ;
}
osm_mad_pool_construct( &openSMObject.mad_pool ) ;
status = osm_mad_pool_init( &openSMObject.mad_pool,
&openSMObject.log );
if ( status != IB_SUCCESS )
{
return status ;
}
return IB_SUCCESS ;
}
ib_api_status_t
opensm_bind(ib_port_attr_t *local_port)
{
// Global Object Handler is already there with maxlid
ib_api_status_t status ;
cl_memcpy(&openSMObject.local_port, local_port,
sizeof(openSMObject.local_port));
openSMObject.max_lid = MAX_LID ;
openSMObject.h_bind = osmv_bind_sa(openSMObject.p_vendor,
&openSMObject.mad_pool,
local_port->port_guid);
if ( openSMObject.h_bind == OSM_BIND_INVALID_HANDLE )
{
status = IB_ERROR ;
return status ;
}
return IB_SUCCESS ;
}
void
opensm_destroy()
{
cl_map_item_t *p_item , *p_next_item ;
if ( openSMObject.p_vendor )
{
osm_vendor_delete( &openSMObject.p_vendor) ;
}
cl_qpool_destroy( &openSMObject.port_pool);
cl_qpool_destroy( &openSMObject.node_pool);
/* Destroy the qMap Table */
p_next_item = cl_qmap_head( &openSMObject.exp_subn.link_tbl );
while ( p_next_item != cl_qmap_end( &openSMObject.exp_subn.link_tbl ) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
p_next_item = cl_qmap_head( &openSMObject.exp_subn.mgrp_mlid_tbl );
while ( p_next_item != cl_qmap_end(
&openSMObject.exp_subn.mgrp_mlid_tbl ) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
p_next_item = cl_qmap_head( &openSMObject.exp_subn.node_guid_tbl);
while ( p_next_item != cl_qmap_end(
&openSMObject.exp_subn.node_guid_tbl) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
p_next_item = cl_qmap_head( &openSMObject.exp_subn.node_lid_tbl);
while ( p_next_item != cl_qmap_end(
&openSMObject.exp_subn.node_lid_tbl) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
p_next_item = cl_qmap_head( &openSMObject.exp_subn.path_tbl);
while ( p_next_item != cl_qmap_end( &openSMObject.exp_subn.path_tbl) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
p_next_item = cl_qmap_head( &openSMObject.exp_subn.port_key_tbl);
while ( p_next_item != cl_qmap_end(
&openSMObject.exp_subn.port_key_tbl) )
{
p_item = p_next_item ;
p_next_item = cl_qmap_next(p_item);
cl_free(p_item) ;
}
// End of the destroy function
}
void
opensm_query_res_cb ( osmv_query_res_t *p_record )
{
printf("\n I m here in the call Back function ");
osmtest_req_context_t *const p_context =
(osmtest_req_context_t *) p_record->query_context ;
osmtest_t *const p_osmt = p_context->p_osmt ;
p_context->result = *p_record ;
if ( p_record->status != IB_SUCCESS )
{
printf("\n Kya Problem Hain Yaar....\n");
exit(0);
}
printf("\n Going back to the caller ");
}
// This function will act as a Saquery for us
// Internally this will maap to the osmtest_stress_large_rmpp function
void
opensm_saquery()
{
ib_api_status_t status = IB_SUCCESS ;
uint64_t num_recs = 0 ;
uint32_t delta_queries = 0 ;
osmtest_req_context_t context ;
ib_node_record_t *node_record ;
ib_service_record_t *service_record ;
ib_path_rec_t *path_record ;
uint32_t i ;
// Query related paramters
osmv_user_query_t user ;
osmv_query_req_t req ;
cl_memclr( &context, sizeof(context) );
cl_memclr( &req, sizeof(req) );
cl_memclr( &user, sizeof(user) );
context.p_osmt = &openSMObject ;
//user.attr_id = IB_MAD_ATTR_NODE_RECORD ;
user.attr_id = IB_MAD_ATTR_PATH_RECORD ;
//user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof(*node_record) >>
3 ) );
user.attr_offset = cl_ntoh16( ( uint16_t ) ( sizeof(*path_record) >> 3
) );
req.query_type = OSMV_QUERY_USER_DEFINED ;
//req.query_type = OSMV_QUERY_ALL_SVC_RECS ;
req.timeout_ms = openSMObject.opt.transaction_timeout ;
req.retry_cnt = openSMObject.opt.retry_count ;
req.flags = OSM_SA_FLAGS_SYNC ;
req.query_context = &context ;
req.pfn_query_cb = opensm_query_res_cb ;
req.p_query_input = &user ;
req.sm_key = 0 ;
status = osmv_query_sa(openSMObject.h_bind, &req) ;
if ( status != IB_SUCCESS )
{
printf("\n Yeh Takshak, something serious during SAQUERY
ohh.....\n");
exit(0);
}
status = context.result.status ;
if ( status != IB_SUCCESS )
{
printf("\n Takshak: Context Result is not correct \n");
exit(0);
}
num_recs = context.result.result_cnt ;
printf("\n Yeh Man, QUERY executed Successfully %d !!!
\n\n\n",num_recs);
for(i =0 ; i < num_recs ; i++ )
{
path_record = osmv_get_query_path_rec(
context.result.p_result_madw, i );
printf("%*sDLID: 0x%04x : SLID: 0x%04x \n", 0 , "",
cl_ntoh16( path_record->dlid),
cl_ntoh16(
path_record->slid));
//osm_dump_path_record( &openSMObject.log, path_record,
OSM_LOG_VERBOSE );
/*
node_record = osmv_get_query_node_rec(
context.result.p_result_madw, i );
printf("%*sLID: 0x%04x Type: %s Name: %.*s\n", 0 , "",
cl_ntoh16( node_record->lid ),
ib_get_node_type_str(
node_record->node_info.node_type ),
100,node_record->node_desc.description);
printf("%*sPorts: %d PortNum: %d PartitionCap: %d\n", 0 , "",
node_record->node_info.num_ports,
ib_node_info_get_local_port_num(
&node_record->node_info ),
cl_ntoh16( node_record->node_info.partition_cap
));
printf("%*sNodeGuid: 0x%016"PRIx64" PortGuid:
0x%016"PRIx64"\n", 0 , "",
cl_ntoh64(
node_record->node_info.node_guid ),
cl_ntoh64(
node_record->node_info.port_guid ));
printf("%*sSystemImageGuid: 0x%016"PRIx64"\n", 0, "", cl_ntoh64(
node_record->node_info.sys_guid ));
printf("%*sBaseVersion: %d SmaVersion: %d VendorID: 0x%x DeviceId: 0x%x
Revision: 0x%x\n",
0 , "", node_record->node_info.base_version,
node_record->node_info.class_version,
cl_ntoh32( ib_node_info_get_vendor_id (
&node_record->node_info ) ),
cl_ntoh16( node_record->node_info.device_id ),
cl_ntoh32( node_record->node_info.revision ) );
printf("-------------------------------------------------------------------------------\n");
printf(
"DEFINE_NODE\n"
"lid 0x%X\n"
"base_version 0x%X\n"
"class_version 0x%X\n"
"node_type 0x%X # (%s)\n"
"num_ports 0x%X\n"
"sys_guid 0x%016"PRIx64" \n"
"node_guid 0x%016"PRIx64" \n"
"port_guid 0x%016"PRIx64" \n"
"partition_cap 0x%X\n"
"device_id 0x%X\n"
"revision 0x%X\n"
"# port_num 0x%X\n"
"# vendor_id 0x%X\n"
"# node_desc %s\n"
"END\n\n",
cl_ntoh16( node_record->lid ),
node_record->node_info.base_version,
node_record->node_info.class_version,
node_record->node_info.node_type,
ib_get_node_type_str( node_record->node_info.node_type ),
node_record->node_info.num_ports,
cl_ntoh64( node_record->node_info.sys_guid ),
cl_ntoh64( node_record->node_info.node_guid ),
cl_ntoh64( node_record->node_info.port_guid ),
cl_ntoh16( node_record->node_info.partition_cap ),
cl_ntoh16( node_record->node_info.device_id ),
cl_ntoh32( node_record->node_info.revision ),
ib_node_info_get_local_port_num( &node_record->node_info ),
cl_ntoh32( ib_node_info_get_vendor_id
( &node_record->node_info ) ),
node_record->node_desc.description );
*/
}
}
int main(int argc, char *argv[])
{
osmtest_opt_t options = { 0 } ;
ib_port_attr_t port_attr ;
ib_net64_t guid = 0 ;
ib_api_status_t status ;
uint32_t log_flags = OSM_LOG_ERROR | OSM_LOG_INFO;
opensm_set_default_options(&options);
// opensm initialization
// openSMObject is global, so not passing through this function API
status = opensm_init(&options, (osm_log_level_t) log_flags );
if ( status != IB_SUCCESS )
{
const char *err_string = ib_get_err_str(status);
if ( err_string == NULL )
{
err_string = "Unknown Error Type" ;
}
printf("\n Error From openSM Initialization \n");
return status;
}
printf("\n openSM initialized successfully \n");
// Get some portID where you need to bind this SM
if ( guid == 0 && !(guid = get_port_guid(guid, &port_attr)))
{
printf("\n We can't proceed further without port_guid \n");
exit(0);
}
// Bind SM with the guid
status = opensm_bind(&port_attr) ;
if ( status != IB_SUCCESS )
{
printf("\n Buinding to the found GUID failed \n");
exit(0);
}
printf("\n Now OPENSM is ready to accept any kind of query ");
pthread_t threadid = NULL ;
// DO whatever operation you would like to carry here
opensm_saquery();
// Destroy the opensm
opensm_destroy();
printf("\n openSM destroyed successfully \n");
return 0;
}_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general
To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general