The M_Key Protection Level for the subnet may now be set
in the config file by specifying a numeric value for
m_key_protection_level (defaults to 0).

Signed-off-by: Jim Foraker <[email protected]>
---
 include/opensm/osm_subnet.h |    1 +
 opensm/osm_lid_mgr.c        |   21 +++++++++++----------
 opensm/osm_link_mgr.c       |    2 +-
 opensm/osm_subnet.c         |    5 +++++
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/include/opensm/osm_subnet.h b/include/opensm/osm_subnet.h
index f8a1f3f..8e96314 100644
--- a/include/opensm/osm_subnet.h
+++ b/include/opensm/osm_subnet.h
@@ -161,6 +161,7 @@ typedef struct osm_subn_opt {
        ib_net64_t sa_key;
        ib_net64_t subnet_prefix;
        ib_net16_t m_key_lease_period;
+        uint8_t m_key_protect_bits;
        uint32_t sweep_interval;
        uint32_t max_wire_smps;
        uint32_t max_wire_smps2;
diff --git a/opensm/osm_lid_mgr.c b/opensm/osm_lid_mgr.c
index b169f6b..dc32c66 100644
--- a/opensm/osm_lid_mgr.c
+++ b/opensm/osm_lid_mgr.c
@@ -887,6 +887,11 @@ static int lid_mgr_set_physp_pi(IN osm_lid_mgr_t * p_mgr,
                   sizeof(p_pi->m_key_lease_period)))
                send_set = TRUE;
 
+       p_pi->mkey_lmc = 0;
+       ib_port_info_set_mpb(p_pi, p_mgr->p_subn->opt.m_key_protect_bits);
+       if (ib_port_info_get_mpb(p_pi) != ib_port_info_get_mpb(p_old_pi))
+               send_set = TRUE; 
+
        /*
           we want to set the timeout for both the switch port 0
           and the CA ports
@@ -908,12 +913,10 @@ static int lid_mgr_set_physp_pi(IN osm_lid_mgr_t * p_mgr,
                           sizeof(p_pi->link_width_enabled)))
                        send_set = TRUE;
 
-               /* M_KeyProtectBits are currently always zero */
-               p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
+               /* p_pi->mkey_lmc is initialized earlier */
+               ib_port_info_set_lmc(p_pi, p_mgr->p_subn->opt.lmc);
                if (ib_port_info_get_lmc(p_pi) !=
-                   ib_port_info_get_lmc(p_old_pi) ||
-                   ib_port_info_get_mpb(p_pi) !=
-                   ib_port_info_get_mpb(p_old_pi))
+                   ib_port_info_get_lmc(p_old_pi))
                        send_set = TRUE;
 
                /* calc new op_vls and mtu */
@@ -994,12 +997,10 @@ static int lid_mgr_set_physp_pi(IN osm_lid_mgr_t * p_mgr,
 
                /* Determine if enhanced switch port 0 and if so set LMC */
                if (osm_switch_sp0_is_lmc_capable(p_node->sw, p_mgr->p_subn)) {
-                       /* M_KeyProtectBits are currently always zero */
-                       p_pi->mkey_lmc = p_mgr->p_subn->opt.lmc;
+                       /* p_pi->mkey_lmc is initialized earlier */
+                        ib_port_info_set_lmc(p_pi, p_mgr->p_subn->opt.lmc);
                        if (ib_port_info_get_lmc(p_pi) !=
-                           ib_port_info_get_lmc(p_old_pi) ||
-                           ib_port_info_get_mpb(p_pi) !=
-                           ib_port_info_get_mpb(p_old_pi))
+                           ib_port_info_get_lmc(p_old_pi))
                                send_set = TRUE;
                }
        }
diff --git a/opensm/osm_link_mgr.c b/opensm/osm_link_mgr.c
index 98eceaf..02fde95 100644
--- a/opensm/osm_link_mgr.c
+++ b/opensm/osm_link_mgr.c
@@ -238,8 +238,8 @@ static int link_mgr_set_physp_pi(osm_sm_t * sm, IN 
osm_physp_t * p_physp,
                                   sizeof(p_pi->m_key_lease_period)))
                                send_set = TRUE;
 
-                       /* M_KeyProtectBits are currently always zero */
                        p_pi->mkey_lmc = 0;
+                       ib_port_info_set_mpb(p_pi, 
sm->p_subn->opt.m_key_protect_bits);
                        if (esp0 == FALSE || sm->p_subn->opt.lmc_esp0)
                                ib_port_info_set_lmc(p_pi, sm->p_subn->opt.lmc);
                        if (ib_port_info_get_lmc(p_old_pi) !=
diff --git a/opensm/osm_subnet.c b/opensm/osm_subnet.c
index 200287a..4f5272f 100644
--- a/opensm/osm_subnet.c
+++ b/opensm/osm_subnet.c
@@ -300,6 +300,7 @@ static const opt_rec_t opt_tbl[] = {
        { "sa_key", OPT_OFFSET(sa_key), opts_parse_net64, NULL, 1 },
        { "subnet_prefix", OPT_OFFSET(subnet_prefix), opts_parse_net64, NULL, 1 
},
        { "m_key_lease_period", OPT_OFFSET(m_key_lease_period), 
opts_parse_net16, NULL, 1 },
+        { "m_key_protection_level", OPT_OFFSET(m_key_protect_bits), 
opts_parse_uint8, NULL, 1 },
        { "sweep_interval", OPT_OFFSET(sweep_interval), opts_parse_uint32, 
NULL, 1 },
        { "max_wire_smps", OPT_OFFSET(max_wire_smps), opts_parse_uint32, NULL, 
1 },
        { "max_wire_smps2", OPT_OFFSET(max_wire_smps2), opts_parse_uint32, 
NULL, 1 },
@@ -894,6 +895,7 @@ void osm_subn_set_default_opt(IN osm_subn_opt_t * p_opt)
        p_opt->sa_key = OSM_DEFAULT_SA_KEY;
        p_opt->subnet_prefix = IB_DEFAULT_SUBNET_PREFIX;
        p_opt->m_key_lease_period = 0;
+        p_opt->m_key_protect_bits = 0;
        p_opt->sweep_interval = OSM_DEFAULT_SWEEP_INTERVAL_SECS;
        p_opt->max_wire_smps = OSM_DEFAULT_SMP_MAX_ON_WIRE;
        p_opt->max_wire_smps2 = p_opt->max_wire_smps;
@@ -1558,6 +1560,8 @@ int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * 
p_opts)
                "m_key 0x%016" PRIx64 "\n\n"
                "# The lease period used for the M_Key on this subnet in 
[sec]\n"
                "m_key_lease_period %u\n\n"
+                "# The protection level used for the M_Key on this subnet\n"
+                "m_key_protection_level %u\n\n"
                "# SM_Key value of the SM used for SM authentication\n"
                "sm_key 0x%016" PRIx64 "\n\n"
                "# SM_Key value to qualify rcv SA queries as 'trusted'\n"
@@ -1639,6 +1643,7 @@ int osm_subn_output_conf(FILE *out, IN osm_subn_opt_t * 
p_opts)
                cl_ntoh64(p_opts->guid),
                cl_ntoh64(p_opts->m_key),
                cl_ntoh16(p_opts->m_key_lease_period),
+                p_opts->m_key_protect_bits,
                cl_ntoh64(p_opts->sm_key),
                cl_ntoh64(p_opts->sa_key),
                cl_ntoh64(p_opts->subnet_prefix),
-- 
1.7.9.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to