Skip to content

Commit

Permalink
ON-12878: Switch to new public cplane API: port zf_emu and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Hughes authored and jfeather-amd committed Jun 19, 2024
1 parent c55ae3d commit d79e232
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 255 deletions.
25 changes: 21 additions & 4 deletions src/include/zf_internal/private/zf_emu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/* SPDX-FileCopyrightText: (c) Advanced Micro Devices, Inc. */
#ifndef __ZF_INTERNAL_ZF_EMU_H__
#define __ZF_INTERNAL_ZF_EMU_H__
#include <netinet/ether.h>
#include <vector>

#ifdef __cplusplus
/* Needed because in C++ an empty struct has a non-zero size. Additionally, a
Expand Down Expand Up @@ -34,19 +36,30 @@ struct efct_tx_ctpio_header

struct ef_vi;
struct zf_stack;
using ci_mac_addr_t = uint8_t[ETH_ALEN];

extern void
zf_emu_intf_add(const char* ifname, cicp_hwport_mask_t rx_hwports,
cicp_hwport_mask_t tx_hwports, uint16_t vlan_id,
cicp_llap_type_t hash_policy, int peer_vi,
zf_emu_intf_add(const char* ifname, int ifindex,
const int* hw_ifindices, size_t n_hw_ifindices,
uint16_t vlan_id, uint32_t encap, int peer_ifindex,
const ci_mac_addr_t mac);

static inline void
zf_emu_intf_add(const char* ifname, int ifindex,
std::initializer_list<int> hw_ifindices, uint16_t vlan_id,
uint32_t encap, int peer_ifindex,
const ci_mac_addr_t mac)
{
return zf_emu_intf_add(ifname, ifindex, hw_ifindices.begin(),
hw_ifindices.size(), vlan_id, encap, peer_ifindex, mac);
}
extern void
zf_emu_remove_all_intfs(void);
extern void
zf_emu_set_dst_mac(const ci_mac_addr_t mac);

extern void
zf_emu_intf_set_tx_hwports(const char* if_name, cicp_hwport_mask_t hwports);
zf_emu_intf_set_intf_up(const char* ifname, bool up);

extern void
zf_emu_intf_set_mac(const char* ifname, ci_mac_addr_t mac);
Expand Down Expand Up @@ -96,5 +109,9 @@ struct emu_stats {
extern struct emu_stats& emu_stats_update(void);
void emu_stats_display(struct emu_stats& stats);

const uint32_t CICP_LLAP_TYPE_XMIT_HASH_LAYER2 = 0x00000008;
const uint32_t CICP_LLAP_TYPE_XMIT_HASH_LAYER34 = 0x00000010;
const uint32_t CICP_LLAP_TYPE_XMIT_HASH_LAYER23 = 0x00000020;

#endif /* __ZF_INTERNAL_ZF_EMU_H__ */

3 changes: 0 additions & 3 deletions src/include/zf_internal/private/zf_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ struct hal_ops_s {
ZFHAL_EF_FDECL(vi_get_mac);
ZFHAL_EF_FDECL(vi_filter_add);
ZFHAL_EF_FDECL(vi_filter_del);
ZFHAL_GEN_FDECL(oo_cp_create, cplane_handle);
ZFHAL_GEN_FDECL(__zf_cplane_get_path, get_path);
ZFHAL_GEN_FDECL(oo_fd_open, oo_fd_open_halop);
ZFHAL_GEN_FDECL(oo_fd_close, oo_fd_close_halop);
Expand Down Expand Up @@ -129,8 +128,6 @@ extern struct hal_ops_s* hal_ops;
#define ef_vi_get_mac hal_ops->vi_get_mac
#define ef_vi_filter_add hal_ops->vi_filter_add
#define ef_vi_filter_del hal_ops->vi_filter_del
#undef oo_cp_create
#define oo_cp_create hal_ops->cplane_handle
#define oo_fd_open hal_ops->oo_fd_open_halop
#define oo_fd_close hal_ops->oo_fd_close_halop
#define oo_dshm_register hal_ops->shm_register
Expand Down
Loading

0 comments on commit d79e232

Please sign in to comment.