[openib-general] [PATCH] beginnings of SMI
Sean Hefty
mshefty at ichips.intel.com
Tue Sep 14 15:18:39 PDT 2004
This patch begins to add in functionality needed by the SMI implementation.
- Sean
--
Index: access/ib_smi.c
===================================================================
--- access/ib_smi.c (revision 0)
+++ access/ib_smi.c (revision 0)
@@ -0,0 +1,125 @@
+/*
+ This software is available to you under a choice of one of two
+ licenses. You may choose to be licensed under the terms of the GNU
+ General Public License (GPL) Version 2, available at
+ <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
+ license, available in the LICENSE.TXT file accompanying this
+ software. These details are also available at
+ <http://openib.org/license.html>.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved.
+ Copyright (c) 2004 Infinicon Corporation. All rights reserved.
+ Copyright (c) 2004 Intel Corporation. All rights reserved.
+ Copyright (c) 2004 Topspin Corporation. All rights reserved.
+ Copyright (c) 2004 Voltaire Corporation. All rights reserved.
+*/
+
+#include <ib_mad.h>
+#include "ib_mad_priv.h"
+
+int smi_process_dr_smp(struct ib_mad_port_private *port_priv,
+ struct ib_smp *smp)
+{
+ u8 hop_ptr, hop_cnt;
+
+ hop_ptr = smp->hop_ptr;
+ hop_cnt = smp->hop_cnt;
+
+ /*
+ * Outgoing MAD processing. "Outgoing" means from initiator to responder.
+ * Section 14.2.2.2, Vol 1 IB spec
+ */
+ if (!ib_get_smp_direction(smp)) {
+ /* C14-9:1 */
+ if (hop_ptr == 0 && hop_cnt)
+ return 0;
+
+ /* C14-9:2 */
+ if (hop_ptr && hop_ptr < hop_cnt) {
+ if (port_priv->device->node_type == IB_NODE_SWITCH) {
+ printk(KERN_NOTICE,
+ "Need to handle DR Mad on switch");
+ }
+ return 0;
+ }
+
+ /* C14-9:3 -- We're at the end of the DR segment of path */
+ if (hop_ptr == hop_cnt) {
+ if (hop_cnt)
+ smp->return_path[hop_ptr] = port_priv->port;
+ smp->hop_ptr++;
+
+ if (port_priv->device->node_type == IB_NODE_SWITCH) {
+ printk(KERN_NOTICE,
+ "Need to handle DR Mad on switch");
+ return 0;
+ } else if (smp->dr_dlid != IB_LID_PERMISSIVE) {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* C14-9:4 -- Hop Pointer = Hop Count + 1 -> give to SMA/SM. */
+ if (hop_ptr == hop_cnt + 1)
+ return 1;
+
+ /* C14-9:5 -- Check for unreasonable hop pointer. */
+ if (hop_ptr > hop_cnt + 1)
+ return 0;
+
+ /* There should be no way of getting here, since one of the if
+ * statements above should have matched, and should have
+ * returned a value.
+ */
+ printk(KERN_ERR, "Unhandled Outgoing DR MAD case.");
+ return 0;
+ } else { /* Returning MAD (From responder to initiator) */
+
+ /* C14-13:1 */
+ if (hop_cnt && hop_ptr == hop_cnt + 1)
+ return 0;
+
+ /* C14-13:2 */
+ if (2 <= hop_ptr && hop_ptr <= hop_cnt) {
+ if (port_priv->device->node_type == IB_NODE_SWITCH) {
+ printk(KERN_NOTICE,
+ "Need to handle DR Mad on switch");
+ }
+ return 0;
+ }
+
+ /* C14-13:3 -- We're at the end of the DR segment of path */
+ if (hop_ptr == 1) {
+ smp->hop_ptr--;
+
+ if (port_priv->device->node_type == IB_NODE_SWITCH) {
+ printk(KERN_NOTICE,
+ "Need to handle DR Mad on switch");
+ return 0;
+ } else if (smp->dr_dlid != IB_LID_PERMISSIVE) {
+ return 0;
+ }
+
+ return 1;
+ }
+
+ /* C14-13:4 -- Hop Pointer = 0 -> give to SM. */
+ if (hop_ptr == 0)
+ return 1;
+
+ /* C14-13:5 -- Check for unreasonable hop pointer. */
+ if (hop_ptr > hop_cnt + 1)
+ return 0;
+ }
+ return 1;
+}
Index: include/ib_mad.h
===================================================================
--- include/ib_mad.h (revision 836)
+++ include/ib_mad.h (working copy)
@@ -60,6 +60,11 @@
#define IB_QP1 cpu_to_be32(1)
#define IB_QP1_QKEY cpu_to_be32(0x80010000)
+#define IB_LID_PERMISSIVE 0xFFFF
+
+#define IB_SMP_DATA_SIZE 64
+#define IB_SMP_MAX_PATH_HOPS 64
+
struct ib_grh {
u32 version_tclass_flow;
u16 paylen;
@@ -82,6 +87,35 @@
u32 attr_mod;
} __attribute__ ((packed));
+struct ib_smp {
+ u8 base_version;
+ u8 mgmt_class;
+ u8 class_version;
+ u8 method;
+ u16 status;
+ u8 hop_ptr;
+ u8 hop_cnt;
+ u64 tid;
+ u16 attr_id;
+ u16 resv;
+ u32 attr_mod;
+ u64 mkey;
+ u16 dr_slid;
+ u16 dr_dlid;
+ u8 reserved[28];
+ u8 data[IB_SMP_DATA_SIZE];
+ u8 initial_path[IB_SMP_MAX_PATH_HOPS];
+ u8 return_path[IB_SMP_MAX_PATH_HOPS];
+} __attribute__ ((packed));
+
+#define IB_SMP_DIRECTION cpu_to_be16(0x8000)
+
+static inline u8
+ib_get_smp_direction(struct ib_smp *smp)
+{
+ return ((smp->status & IB_SMP_DIRECTION) == IB_SMP_DIRECTION);
+}
+
struct ib_rmpp_hdr {
u8 rmpp_version;
u8 rmpp_type;
More information about the general
mailing list