From d784e50747b8cf0ce505489e1451f75be5ccbd4b Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 9 Jan 2016 13:13:37 +0100 Subject: Introduce new phy_link and phy_instance abstraction This way we can model a flexible mapping between any number of PHYs, each having multiple instances, and then map BTSs with TRXx on top of those PHYs. --- include/osmo-bts/phy_link.h | 115 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 include/osmo-bts/phy_link.h (limited to 'include/osmo-bts/phy_link.h') diff --git a/include/osmo-bts/phy_link.h b/include/osmo-bts/phy_link.h new file mode 100644 index 00000000..b9fc4121 --- /dev/null +++ b/include/osmo-bts/phy_link.h @@ -0,0 +1,115 @@ +#pragma once + +#include +#include + +#include + +#include + +struct gsm_bts_trx; + +enum phy_link_type { + PHY_LINK_T_NONE, + PHY_LINK_T_SYSMOBTS, + PHY_LINK_T_OSMOTRX, +}; + +enum phy_link_state { + PHY_LINK_SHUTDOWN, + PHY_LINK_CONNECTING, + PHY_LINK_CONNECTED, +}; + +/* A PHY link represents the connection to a given PHYsical layer + * implementation. That PHY link contains 1...N PHY instances, one for + * each TRX */ +struct phy_link { + struct llist_head list; + int num; + enum phy_link_type type; + enum phy_link_state state; + struct llist_head instances; + char *description; + union { + struct { + } sysmobts; + struct { + char *transceiver_ip; + uint16_t base_port_local; + uint16_t base_port_remote; + struct osmo_fd trx_ofd_clk; + + uint32_t clock_advance; + uint32_t rts_advance; + + int rxgain_valid; + int rxgain; + int rxgain_sent; + + int power_valid; + int power; + int power_oml; + int power_sent; + } osmotrx; + struct { + /* MAC address of the PHY */ + struct sockaddr_ll phy_addr; + /* Network device name */ + char *netdev_name; + + /* configuration */ + uint32_t rf_port_index; + uint32_t rx_gain_db; + uint32_t tx_atten_db; + + struct octphy_hdl *hdl; + } octphy; + } u; +}; + +struct phy_instance { + /* liked inside phy_link.linstances */ + struct llist_head list; + int num; + char *description; + + /* pointer to the PHY link to which we belong */ + struct phy_link *phy_link; + + /* back-pointer to the TRX to which we're associated */ + struct gsm_bts_trx *trx; + + union { + struct { + } sysmobts; + struct { + struct trx_l1h *hdl; + } osmotrx; + struct { + /* logical transceiver number within one PHY */ + uint32_t trx_id; + } octphy; + } u; +}; + +struct phy_link *phy_link_by_num(int num); +struct phy_link *phy_link_create(void *ctx, int num); +void phy_link_destroy(struct phy_link *plink); +void phy_link_state_set(struct phy_link *plink, enum phy_link_state state); +int phy_links_open(void); + +struct phy_instance *phy_instance_by_num(struct phy_link *plink, int num); +struct phy_instance *phy_instance_create(struct phy_link *plink, int num); +void phy_instance_link_to_trx(struct phy_instance *pinst, struct gsm_bts_trx *trx); +void phy_instance_destroy(struct phy_instance *pinst); +const char *phy_instance_name(struct phy_instance *pinst); + +void phy_user_statechg_notif(struct phy_instance *pinst, enum phy_link_state link_state); + +static inline struct phy_instance *trx_phy_instance(struct gsm_bts_trx *trx) +{ + return trx->role_bts.l1h; +} + +int bts_model_phy_link_open(struct phy_link *plink); -- cgit v1.2.3