/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
extern int ibmf_trace_level;
/* These functions have only been tested on a big-endian system */
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
void *record);
/*
* *_record_parse_buffer functions:
*
* Each of these functions parses a buffer containing a single SA record.
* The function copies the buffer into a structure taking care of any padding
* and byte-endianness issues. There is one function for each of the 22
* attributes (Table 155).
*
* ibmf_utils_unpack_data() must be called for each structure in the structure
* since Solaris will align the internal structure on a 64-bit boundary, even if
* the first element is a 32-bit value.
*
* Input Arguments
* buffer pointer character array containing raw data
*
* Output Arguments
* record pointer to the SA attribute structure
*
* Returns void
*/
static void
{
}
static void
{
notice, sizeof (ib_mad_notice_t));
}
static void
{
informinfo, sizeof (ib_mad_informinfo_t));
}
static void
{
/* first get record identifier information */
node_record, 4);
/* next get node info */
}
static void
{
/* first get record identifier information */
portinfo_record, 4);
/* next get portinfo info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
SLtoVLmapping_record, 8);
/* SLtoVL mapping has 4 reserved bytes between RID and attribute */
/* next get SLtoVLmapping info */
sizeof (sm_SLtoVL_mapping_table_t));
}
static void
{
/* first get record identifier information */
switchinfo_record, 4);
/* next get switchinfo info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
linearft_record, 8);
/* LFT has 4 reserved bytes between RID and attribute */
/* next get linearft info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
randomft_record, 8);
/* RFT has 4 reserved bytes between RID and attribute */
/* next get randomft info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
multicastft_record, 8);
/* MFT has 4 reserved bytes between RID and attribute */
/* next get multicastft info */
sizeof (sm_multicast_forwarding_table_t));
}
static void
{
/* first get record identifier information */
sminfo_record, 4);
/* next get sminfo info */
sizeof (sm_sminfo_t));
}
static void
{
/* first get record identifier information */
informinfo_record, 18);
/* InformInfo has 6 reserved bytes between RID and attribute */
/* next get informinfo info */
sizeof (ib_mad_informinfo_t));
}
static void
{
link_record, sizeof (sa_link_record_t));
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
guidinfo_record, 8);
/* GUIDInfo has 4 reserved bytes between RID and attribute */
/* next get guidinfo info */
}
static void
{
sizeof (sa_service_record_t));
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
partition_record, 8);
/* Partition record has 3 reserved bytes between RID and attribute */
/* next get partition info */
}
static void
{
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
VLarb_table_record, 8);
/* VLarb record has 4 reserved bytes between RID and attribute */
/* next get VLarb_table info */
sizeof (sm_VLarb_table_t));
}
static void
{
mcmember_record, sizeof (sa_mcmember_record_t));
}
static void
{
trace_record, sizeof (sa_trace_record_t));
}
/*
* ibmf_saa_multipath_record_parse_buffer:
*
* First unpack the standard part of the multipath record. Then find the number
* of gids and unpack those. This function will probably never be called as the
* ibmf_saa should not receive any multipath records. It's in here for
* completeness.
*/
void *record)
{
sizeof (sa_multipath_record_t));
multipath_record + sizeof (sa_multipath_record_t),
}
static void
{
service_assn_record, sizeof (sa_service_assn_record_t));
}
void
{
sm_trap_64, sizeof (sm_trap_64_t));
}
void
{
sm_trap_144, sizeof (sm_trap_144_t));
}
void
{
sm_trap_145, sizeof (sm_trap_145_t));
}
/*
* *_record_to_buf functions:
*
* Each of these functions copies a single SA record out of a structure and into
* a buffer for sending on the wire. The function will take care of any padding
* and byte-endianness isues. There is one function for each of the 22
* attributes (Table 155).
*
* ibmf_utils_pack_data() must be called for each structure in the structure
* since Solaris will align the internal structure on a 64-bit boundary, even if
* the first element is a 32-bit value.
*
* Input Arguments
* record pointer to the structure to be parsed
*
* Output Arguments
* buffer pointer to array to place the data in (allocated by caller)
*
* Returns void
*/
static void
{
ibmf_utils_pack_data("2csl2Ll2s2l2Ll2s2l",
cpi, sizeof (ib_mad_classportinfo_t),
}
static void
{
}
static void
{
}
static void
{
/* first get record identifier information */
/* next get node info */
/* next get node description */
}
static void
{
/* first get record identifier information */
/* next get portinfo info */
ibmf_utils_pack_data("LLsslss16c3s4c",
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* SLtoVL mapping has 4 reserved bytes between RID and attribute */
/* next get SLtoVLmapping info */
}
static void
{
/* first get record identifier information */
/* next get switchinfo info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* LFT has 4 reserved bytes between RID and attribute */
/* next get linearft info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* RFT has 4 reserved bytes between RID and attribute */
/* next get randomft info */
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* MFT has 4 reserved bytes between RID and attribute */
/* next get multicastft info */
sizeof (sm_multicast_forwarding_table_t), buffer,
}
static void
{
/* first get record identifier information */
/* next get sminfo info */
}
static void
{
/* first get record identifier information */
/* InformInfo has 6 reserved bytes between RID and attribute */
/* next get informinfo info */
}
static void
{
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* GUIDInfo has 4 reserved bytes between RID and attribute */
/* next get guidinfo info */
}
static void
{
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* Partition record has 3 reserved bytes between RID and attribute */
/* next get partition info */
}
static void
{
}
static void
{
/* first get record identifier information (plus 4 bytes reserved) */
/* VLarb record has 4 reserved bytes between RID and attribute */
/* next get VLarb_table info */
}
static void
{
sizeof (sa_mcmember_record_t),
}
{
}
static void
{
sizeof (sa_service_assn_record_t),
}
int
{
if (*packed_class_hdr == NULL) {
"could not allocate memory for header\n");
return (IBMF_NO_MEMORY);
}
return (IBMF_SUCCESS);
}
int
{
if (packed_class_hdr_len != IBMF_SAA_HDR_SIZE) {
" sa_class_hdr_len = %d, pkt_class_hdr_len = %d\n",
return (IBMF_REQ_INVALID);
}
"could not allocate memory for header\n");
return (IBMF_NO_MEMORY);
}
return (IBMF_SUCCESS);
}
/*
* ibmf_saa_utils_pack_payload:
*
* Takes a pointer to an array of sa record structures. For each element packs
* the structure into a character buffer removing any padding and account for
* endianness issues.
*
*/
int
{
int i;
int num_records;
void (*pack_data_fn)(void *, uchar_t *);
if (structs_payload_length == 0) {
*buf_payloadp = NULL;
return (IBMF_SUCCESS);
}
/* trace records should never be sent (or packed) by ibmf_saa */
switch (attr_id) {
case SA_CLASSPORTINFO_ATTRID:
struct_size = sizeof (ib_mad_classportinfo_t);
break;
case SA_NOTICE_ATTRID:
struct_size = sizeof (ib_mad_notice_t);
break;
case SA_INFORMINFO_ATTRID:
struct_size = sizeof (ib_mad_informinfo_t);
break;
case SA_NODERECORD_ATTRID:
struct_size = sizeof (sa_node_record_t);
break;
case SA_PORTINFORECORD_ATTRID:
struct_size = sizeof (sa_portinfo_record_t);
break;
case SA_SLTOVLRECORD_ATTRID:
struct_size = sizeof (sa_SLtoVLmapping_record_t);
break;
struct_size = sizeof (sa_switchinfo_record_t);
break;
struct_size = sizeof (sa_linearft_record_t);
break;
struct_size = sizeof (sa_randomft_record_t);
break;
struct_size = sizeof (sa_multicastft_record_t);
break;
case SA_SMINFORECORD_ATTRID:
struct_size = sizeof (sa_sminfo_record_t);
break;
struct_size = sizeof (sa_informinfo_record_t);
break;
case SA_LINKRECORD_ATTRID:
struct_size = sizeof (sa_link_record_t);
break;
case SA_GUIDINFORECORD_ATTRID:
struct_size = sizeof (sa_guidinfo_record_t);
break;
case SA_SERVICERECORD_ATTRID:
struct_size = sizeof (sa_service_record_t);
break;
struct_size = sizeof (sa_pkey_table_record_t);
break;
case SA_PATHRECORD_ATTRID:
struct_size = sizeof (sa_path_record_t);
break;
case SA_VLARBRECORD_ATTRID:
struct_size = sizeof (sa_VLarb_table_record_t);
break;
case SA_MCMEMBERRECORD_ATTRID:
struct_size = sizeof (sa_mcmember_record_t);
break;
/*
* array is of size 1 since multipath can be request
* only; data size greater than multipath_record_t
* size is due to gids at the end
*/
struct_size - sizeof (sa_multipath_record_t);
break;
struct_size = sizeof (sa_service_assn_record_t);
break;
default:
/* don't know about structure; do bcopy */
if (*buf_payloadp == NULL) {
*buf_payload_lengthp = 0;
return (IBMF_NO_MEMORY);
}
return (IBMF_SUCCESS);
}
if (*buf_payloadp == NULL) {
" size = %d\n",
*buf_payload_lengthp = 0;
return (IBMF_NO_MEMORY);
}
for (i = 0; i < num_records; i++) {
}
return (IBMF_SUCCESS);
}
/*
* ibmf_saa_utils_unpack_payload:
*
* Unpacks a buffer of data received over the wire and places into an array of
* structure in host format.
*
* for getResp() ibmf always reports payload length as 200 bytes
* (MAD_SIZE - headers). To keep the client from having to determine the actual
* length of the one attribute (since we do it here) the is_get_resp parameter
* indicates that there is one attribute in the buffer.
*/
int
{
int i;
int num_records;
void (*unpack_data_fn)(uchar_t *, void *);
int bytes_between_recs;
if (buf_payload_length == 0) {
*structs_payload_lengthp = 0;
*structs_payloadp = NULL;
return (IBMF_SUCCESS);
}
switch (attr_id) {
case SA_CLASSPORTINFO_ATTRID:
struct_size = sizeof (ib_mad_classportinfo_t);
break;
case SA_NOTICE_ATTRID:
struct_size = sizeof (ib_mad_notice_t);
break;
case SA_INFORMINFO_ATTRID:
struct_size = sizeof (ib_mad_informinfo_t);
break;
case SA_NODERECORD_ATTRID:
struct_size = sizeof (sa_node_record_t);
break;
case SA_PORTINFORECORD_ATTRID:
struct_size = sizeof (sa_portinfo_record_t);
break;
case SA_SLTOVLRECORD_ATTRID:
struct_size = sizeof (sa_SLtoVLmapping_record_t);
break;
struct_size = sizeof (sa_switchinfo_record_t);
break;
struct_size = sizeof (sa_linearft_record_t);
break;
struct_size = sizeof (sa_randomft_record_t);
break;
struct_size = sizeof (sa_multicastft_record_t);
break;
case SA_SMINFORECORD_ATTRID:
struct_size = sizeof (sa_sminfo_record_t);
break;
struct_size = sizeof (sa_informinfo_record_t);
break;
case SA_LINKRECORD_ATTRID:
struct_size = sizeof (sa_link_record_t);
break;
case SA_GUIDINFORECORD_ATTRID:
struct_size = sizeof (sa_guidinfo_record_t);
break;
case SA_SERVICERECORD_ATTRID:
struct_size = sizeof (sa_service_record_t);
break;
struct_size = sizeof (sa_pkey_table_record_t);
break;
case SA_PATHRECORD_ATTRID:
struct_size = sizeof (sa_path_record_t);
break;
case SA_VLARBRECORD_ATTRID:
struct_size = sizeof (sa_VLarb_table_record_t);
break;
case SA_MCMEMBERRECORD_ATTRID:
struct_size = sizeof (sa_mcmember_record_t);
break;
case SA_TRACERECORD_ATTRID:
struct_size = sizeof (sa_trace_record_t);
break;
/*
* array is of size 1 since multipath can be request
* only; data size greater than multipath_record_t
* size is due to gids at the end
*/
struct_size = sizeof (sa_multipath_record_t) +
break;
struct_size = sizeof (sa_service_assn_record_t);
break;
default:
/* don't know about structure; do bcopy */
if (*structs_payloadp == NULL) {
*structs_payload_lengthp = 0;
return (IBMF_NO_MEMORY);
}
return (IBMF_SUCCESS);
}
/* compute distance between successive records */
if (attr_offset > 0) {
"ibmf_saa_utils_unpack_payload: %s, attr_offset = "
"%d, attr_size = %d\n",
" than attribute size",
return (IBMF_TRANS_FAILURE);
}
} else {
}
if (is_get_resp == B_TRUE) {
num_records = 1;
} else {
}
if (*structs_payloadp == NULL) {
" size = %d\n",
*structs_payload_lengthp = 0;
return (IBMF_NO_MEMORY);
}
for (i = 0; i < num_records; i++) {
(void *)((uchar_t *)*structs_payloadp + i *
struct_size));
}
return (IBMF_SUCCESS);
}