Skip to content

Commit

Permalink
Merge pull request #177 from mklight/fapi2_multicast_part_2
Browse files Browse the repository at this point in the history
Fapi2 multicast part 2
  • Loading branch information
mklight authored Feb 13, 2019
2 parents 7712d20 + 8daa218 commit 4ba23a9
Show file tree
Hide file tree
Showing 13 changed files with 520 additions and 40 deletions.
2 changes: 1 addition & 1 deletion ecmd-core/capi/ecmdStructs.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// Defines
//--------------------------------------------------------------------

#define ECMD_CAPI_VERSION "14.14" ///< eCMD API Version
#define ECMD_CAPI_VERSION "14.15" ///< eCMD API Version

// Magic headers for packing/unpacking the ecmdQueryData structure heirarchy.
#define QD_HDR_MAGIC 0xFFFFFFF1
Expand Down
12 changes: 7 additions & 5 deletions ecmd-core/ext/fapi2/capi/error_info.H
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ inline uint64_t convertType( T& i_value )
};

// convert platform target handle to a uint64_t
template<fapi2::TargetType T>
inline uint64_t convertType( const fapi2::Target<T>& i_value)
template<fapi2::TargetType T, fapi2::MulticastType M>
inline uint64_t convertType( const fapi2::Target<T, M>& i_value)
{
// send the target type and instance as ffdc they will be used
// to instantiate a target before logging the ffdc data
return static_cast<uint64_t>((static_cast<uint64_t>(
(i_value.get().getFapiTargetType())) << 32) |
i_value.get().getTargetInstance());
return static_cast<uint64_t>(
(static_cast<uint64_t>(
(i_value.get().getFapiTargetType() |
(i_value.get().fields.is_multicast << 31))
) << 32) | i_value.get().getTargetInstance());
};
#endif

Expand Down
3 changes: 3 additions & 0 deletions ecmd-core/ext/fapi2/capi/fapi2ClientEnums.H
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ ECMD_FAPI2PUTI2C,
ECMD_FAPI2GETMMIO,
ECMD_FAPI2PUTMMIO,
ECMD_FAPI2GETFILTEREDTARGETS,
ECMD_FAPI2SETMCASTGROUPMAP,
ECMD_FAPI2GETSCOMMULTICAST,
ECMD_FAPI2PUTSCOMMULTICAST,
FAPI2_NUMFUNCTIONS
} fapi2FunctionIndex_t;

Expand Down
14 changes: 14 additions & 0 deletions ecmd-core/ext/fapi2/capi/fapi2DllCapi.H
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ uint32_t dllFapi2PutMMIO(const ecmdChipTarget& i_target,
const size_t i_transSize,
const std::vector<uint8_t>& i_data);

uint32_t dllFapi2SetMcastGroupMap(const ecmdChipTarget & i_target,
const std::vector< fapi2::MulticastGroupMapping > & i_mappings);

uint32_t dllFapi2GetScomMulticast(const ecmdChipTarget& i_target,
const uint32_t i_type,
const uint32_t i_group,
const uint64_t i_address,
ecmdDataBuffer& o_data);

uint32_t dllFapi2PutScomMulticast(const ecmdChipTarget& i_target,
const uint32_t i_type,
const uint32_t i_group,
const uint64_t i_address,
const ecmdDataBuffer& i_data);
} //extern C

#endif
26 changes: 23 additions & 3 deletions ecmd-core/ext/fapi2/capi/fapi2_hw_access.H
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ inline void setOpMode(const OpModes i_mode);
/// @return the operational mode
inline OpModes getOpMode(void);

//--------------------------------------------------------------------------
// Multicast mapping functions
//--------------------------------------------------------------------------

/// @brief Set up or replace the multicast group mapping for a given chip
/// @param[in] i_chip The chip whose multicast map is to be replaced
/// @param[in] i_mappings A list of multicast group mappings
/// @return FAPI2_RC_SUCCESS if the map was updated, otherwise error code.
///
/// This replaces the given chip's map of abstract multicast groups to chip
/// specific hardware values with a new map. Any abstract group not explicitly
/// mapped via i_mappings will be unmapped after this call returns success,
/// and attempting to create multicast targets targeting unmapped groups will
/// result in error.
/// i_mappings may contain an arbitrary amount of abstract/HW pairs, but the
/// function may return an error if too many mappings are specified.
template< MulticastType M, typename V >
inline ReturnCode setMulticastGroupMap(const Target<TARGET_TYPE_PROC_CHIP, M, V>& i_chip,
const std::vector< MulticastGroupMapping >& i_mappings);

//--------------------------------------------------------------------------
// HW Communication Functions
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -168,7 +188,7 @@ template< TargetType K, MulticastType M, typename V >
inline ReturnCode getRing(const Target<K, M, V>& i_target,
const scanRingId_t i_address,
variable_buffer& o_data,
const RingMode i_ringMode = 0);
const RingMode i_ringMode = RING_MODE_HEADER_CHECK);

/// @brief Read-modify-write a ring on a chip.
/// @tparam K template parameter, passed in target.
Expand All @@ -184,7 +204,7 @@ inline ReturnCode modifyRing(const Target<K, M, V>& i_target,
const scanRingId_t i_address,
const variable_buffer& i_data,
const ChipOpModifyMode i_modifyMode,
const RingMode i_ringMode = 0);
const RingMode i_ringMode = RING_MODE_HEADER_CHECK);
#endif

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -322,7 +342,7 @@ inline ReturnCode putSpy(const Target<K, M, V>& i_target,
const char* const i_spyId,
const variable_buffer& i_data);

template<TargetType K, MulticastType M, typename V >
template< TargetType K, MulticastType M, typename V >
inline ReturnCode putSpyWithCare(const Target<K, M, V>& i_target,
const char* const i_spyId,
const variable_buffer& i_data,
Expand Down
59 changes: 52 additions & 7 deletions ecmd-core/ext/fapi2/capi/fapi2_target.H
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,16 @@ class Target
iv_handle(Value)
{
plat_apply_target_limits<K, M, V>();
};

/* Iff this is a potential mcast target, update the handle.
* We can't know the mcast op of the V handed in, so we have
* to incur the cost of the update even if unnecessary.
*/
if (K & TARGET_TYPE_MULTICAST)
{
mcUpdateHandle();
}
};

///
/// @brief Assignment Operator.
Expand Down Expand Up @@ -302,6 +310,36 @@ class Target
getChildren(const TargetFilter i_filter,
const TargetState i_state = TARGET_STATE_FUNCTIONAL) const;

///
/// @brief Get a multicast target for a given chip
/// @tparam T The type of target to return; TARGET_TYPE_MULTICAST is added automatically
/// @tparam O The type of multicast read operation for the target; defaults to OR
/// @param[in] i_group The abstract multicast group the target should point to
/// @return The multicast target
///
/// This method is only applicable to chip-level targets.
/// If the requested multicast group cannot be mapped to an available HW multicast
/// group, a platform specific error will be thrown.
///
template< TargetType T, MulticastType O = MULTICAST_OR >
inline Target < T | TARGET_TYPE_MULTICAST, O, V >
getMulticast(const MulticastGroup i_group) const;

///
/// @brief Get a multicast core target for a given chip
/// @tparam O The type of multicast read operation for the target; defaults to OR
/// @param[in] i_group The abstract multicast group (selecting EQs) the target should point to
/// @param[in] i_cores Which cores inside the selected EQ should be targeted
/// @return The multicast target
///
/// This method is only applicable to chip-level targets.
/// If the requested multicast group cannot be mapped to an available HW multicast
/// group, a platform specific error will be thrown.
///
template< MulticastType O = MULTICAST_OR >
inline Target < TARGET_TYPE_CORE | TARGET_TYPE_MULTICAST, O, V >
getMulticast(const MulticastGroup i_group, const MulticastCoreSelect i_cores) const;

///
/// @brief Get the target at the other end of a bus
/// @tparam T The type of the target on the other end
Expand All @@ -320,7 +358,6 @@ class Target
/// @brief Is the target functional?
/// @return true if target is functional, false if non-functional
///

inline bool
isFunctional(void) const;

Expand All @@ -329,18 +366,20 @@ class Target
/// @return The chiplet number for the Target. 0 is returned if the
/// Target does not have a chiplet number (for ex, the PROC_CHIP Target)
/// @note For logical targets such as the EX, the chiplet number of
/// their immediate parent chiplet is returned
/// their immediate parent chiplet is returned. For multicast targets
/// getChipletNumber() is not supported.
///
inline uint8_t
getChipletNumber(void) const;

///
/// @brief Copy from a Target<O> to a Target<K>
/// @brief Copy from a Target<O, MO> to a Target<K, M>
/// @tparam O the target type of the other
/// @tparam MO the multicast type of the other
///
template<TargetType O, MulticastType MO, typename VO>
inline Target( const Target<O, MO, VO>& Other ):
Target<K, M, V>(Other.get())
template<TargetType O, MulticastType MO>
inline Target( const Target<O, MO, V>& Other ):
iv_handle(Other.get())
{
plat_apply_target_limits<K, M, V>();

Expand All @@ -350,6 +389,12 @@ class Target

static_assert( bitCount<K>::count >= bitCount<O>::count,
"unable to cast to specialized Target");

// Only need to update the handle if we're coming from a target that's already MULTICAST
if ((O & TARGET_TYPE_MULTICAST) && (MO != M))
{
mcUpdateHandle();
}
}

private:
Expand Down
43 changes: 43 additions & 0 deletions ecmd-core/ext/fapi2/capi/hw_access.H
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,49 @@ inline OpModes getOpMode(void)
return NORMAL;
}

//--------------------------------------------------------------------------
// Multicast mapping functions
//--------------------------------------------------------------------------

/// @brief Set up or replace the multicast group mapping for a given chip
/// @param[in] i_chip The chip whose multicast map is to be replaced
/// @param[in] i_mappings A list of multicast group mappings
/// @return FAPI2_RC_SUCCESS if the map was updated, otherwise error code.
///
/// This replaces the given chip's map of abstract multicast groups to chip
/// specific hardware values with a new map. Any abstract group not explicitly
/// mapped via i_mappings will be unmapped after this call returns success,
/// and attempting to create multicast targets targeting unmapped groups will
/// result in error.
/// i_mappings may contain an arbitrary amount of abstract/HW pairs, but the
/// function may return an error if too many mappings are specified.
template< MulticastType M, typename V >
inline ReturnCode setMulticastGroupMap(const Target<TARGET_TYPE_PROC_CHIP, M, V>& i_chip,
const std::vector< MulticastGroupMapping >& i_mappings)
{
ReturnCode l_rc;
bool l_traceit = fapi2plat::isScanTraceEnabled();

// call the platform implementation
l_rc = fapi2plat::setMulticastGroupMap( i_chip, i_mappings );

if (l_rc != FAPI2_RC_SUCCESS)
{
char target_string[MAX_ECMD_STRING_LEN];
fapi2::toString(i_chip, target_string, MAX_ECMD_STRING_LEN);
FAPI_ERR("setMulticastGroupMap failed - Target %s", target_string);
}

if( l_traceit )
{
char target_string[MAX_ECMD_STRING_LEN];
fapi2::toString(i_chip, target_string, MAX_ECMD_STRING_LEN);
FAPI_SCAN( "TRACE : SETMCGRPMAP : %s : ", target_string );
}

return l_rc;
}

//------------------------------------------------------------------------------
// HW Communication Functions to be implemented at the platform layer.
//------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions ecmd-core/ext/fapi2/capi/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SCRIPTS += scripts/parseErrorInfo.pl
# Additional Source files for the Client API
CAPI_SOURCE := plat_utils.C
CAPI_SOURCE += plat_hw_access.C
CAPI_SOURCE += plat_hw_access_multicast.C
CAPI_SOURCE += plat_i2c_access.C
CAPI_SOURCE += plat_mmio_access.C
CAPI_SOURCE += plat_vpd_access.C
Expand Down
45 changes: 44 additions & 1 deletion ecmd-core/ext/fapi2/capi/multicast_defs.H
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,50 @@ enum MulticastType
MULTICAST_COMPARE = 4,
};

typedef uint32_t MulticastGroup;
/**
* @brief Abstract multicast group definitions
*
* These are abstract multicast groups that a procedure may want to talk to.
* They are being mapped to hardware MC group IDs by the platform layer.
* Due to the limited amount of hardware MC groups, the availability of
* certain abstract groups will be dependent on system state, for example
* the currently executing istep.
*
* The actual multicast group enumerations will be defined in a project specific header.
*/
enum MulticastGroup : uint32_t;

/**
* @brief Single FAPI->HW multicast group mapping
*
* This is used to provide a mapping of an abstract MulticastGroup to a hardware dependent
* value. The calling HWP and platform layer must have the same understanding of the HW
* value (e.g. PCB multicast group ID), FAPI2 is only the conduit and imposes no restriction
* on hwValue.
*/
struct MulticastGroupMapping
{
MulticastGroup abstractGroup;
uint32_t hwValue;
};

/**
* @brief Bit mask for selecting cores out of an EQ.
*/
enum MulticastCoreSelect
{
MCCORE_0 = 0x8,
MCCORE_1 = 0x4,
MCCORE_2 = 0x2,
MCCORE_3 = 0x1,
MCCORE_ALL = 0xF,
};

inline MulticastCoreSelect operator|(const MulticastCoreSelect a, const MulticastCoreSelect b)
{
return static_cast<MulticastCoreSelect>(a | b);
}

}

#endif
Loading

0 comments on commit 4ba23a9

Please sign in to comment.