Skip to content

Commit

Permalink
st2110/video: find socket from MTL_SESSION_PORT_P (#899)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <frank.du@intel.com>
  • Loading branch information
frankdjx committed Jun 12, 2024
1 parent 9d87d0d commit 34a3a77
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 18 deletions.
19 changes: 19 additions & 0 deletions lib/src/mt_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,25 @@ void mt_mbuf_sanity_check(struct rte_mbuf** mbufs, uint16_t nb, char* tag) {
}
}

enum mtl_port mt_port_by_name(struct mtl_main_impl* impl, const char* name) {
struct mtl_init_params* p = mt_get_user_params(impl);
int main_num_ports = p->num_ports;

if (!name) {
err("%s, name is NULL\n", __func__);
return MTL_PORT_MAX;
}

for (enum mtl_port i = 0; i < main_num_ports; i++) {
if (0 == strncmp(p->port[i], name, MTL_PORT_MAX_LEN)) {
return i;
}
}

err("%s, %s is not valid\n", __func__, name);
return MTL_PORT_MAX;
}

int mt_build_port_map(struct mtl_main_impl* impl, char** ports, enum mtl_port* maps,
int num_ports) {
struct mtl_init_params* p = mt_get_user_params(impl);
Expand Down
1 change: 1 addition & 0 deletions lib/src/mt_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ int mt_audio_pacing_train_result_add(struct mtl_main_impl* impl, enum mtl_port p
int mt_audio_pacing_train_result_search(struct mtl_main_impl* impl, enum mtl_port port,
uint64_t input_bps, uint64_t* profiled_bps);

enum mtl_port mt_port_by_name(struct mtl_main_impl* impl, const char* name);
int mt_build_port_map(struct mtl_main_impl* impl, char** ports, enum mtl_port* maps,
int num_ports);

Expand Down
6 changes: 4 additions & 2 deletions lib/src/st2110/pipeline/st20_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,6 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) {
int idx = st20p_rx_idx;
size_t dst_size = 0;
bool auto_detect = ops->flags & ST20P_RX_FLAG_AUTO_DETECT ? true : false;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

Expand All @@ -956,6 +954,10 @@ st20p_rx_handle st20p_rx_create(mtl_handle mt, struct st20p_rx_ops* ops) {
}
}

enum mtl_port port = mt_port_by_name(impl, ops->port.port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST20P_RX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST20P_RX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/st2110/pipeline/st20_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,6 @@ st20p_tx_handle st20p_tx_create(mtl_handle mt, struct st20p_tx_ops* ops) {
int ret;
int idx = st20p_tx_idx;
size_t src_size;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

Expand All @@ -796,6 +794,10 @@ st20p_tx_handle st20p_tx_create(mtl_handle mt, struct st20p_tx_ops* ops) {
return NULL;
}

enum mtl_port port = mt_port_by_name(impl, ops->port.port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST20P_TX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST20P_TX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/st2110/pipeline/st22_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ st22p_rx_handle st22p_rx_create(mtl_handle mt, struct st22p_rx_ops* ops) {
int idx = st22p_rx_idx;
size_t dst_size;
enum st_frame_fmt codestream_fmt;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

Expand All @@ -677,6 +675,10 @@ st22p_rx_handle st22p_rx_create(mtl_handle mt, struct st22p_rx_ops* ops) {
return NULL;
}

enum mtl_port port = mt_port_by_name(impl, ops->port.port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST22P_RX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST22P_RX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/st2110/pipeline/st22_pipeline_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,6 @@ st22p_tx_handle st22p_tx_create(mtl_handle mt, struct st22p_tx_ops* ops) {
int idx = st22p_tx_idx;
size_t src_size;
enum st_frame_fmt codestream_fmt;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

Expand All @@ -794,6 +792,10 @@ st22p_tx_handle st22p_tx_create(mtl_handle mt, struct st22p_tx_ops* ops) {
return NULL;
}

enum mtl_port port = mt_port_by_name(impl, ops->port.port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST22P_TX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST22P_TX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down
12 changes: 8 additions & 4 deletions lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -3950,8 +3950,6 @@ st20_rx_handle st20_rx_create_with_mask(struct mtl_main_impl* impl,
struct st_rx_video_session_impl* s;
int quota_mbs, ret, quota_mbs_wo_dma = 0;
uint64_t bps;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

if (impl->type != MT_HANDLE_MAIN) {
err("%s, invalid type %d\n", __func__, impl->type);
Expand Down Expand Up @@ -3987,6 +3985,10 @@ st20_rx_handle st20_rx_create_with_mask(struct mtl_main_impl* impl,
}
}

enum mtl_port port = mt_port_by_name(impl, ops->port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST20_RX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST20_RX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down Expand Up @@ -4337,8 +4339,6 @@ st22_rx_handle st22_rx_create(mtl_handle mt, struct st22_rx_ops* ops) {
int quota_mbs, ret;
uint64_t bps;
struct st20_rx_ops st20_ops;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

if (impl->type != MT_HANDLE_MAIN) {
err("%s, invalid type %d\n", __func__, impl->type);
Expand Down Expand Up @@ -4372,6 +4372,10 @@ st22_rx_handle st22_rx_create(mtl_handle mt, struct st22_rx_ops* ops) {
quota_mbs *= ops->num_port;
}

enum mtl_port port = mt_port_by_name(impl, ops->port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST22_RX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST22_RX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down
14 changes: 8 additions & 6 deletions lib/src/st2110/st_tx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -3969,9 +3969,6 @@ st20_tx_handle st20_tx_create(mtl_handle mt, struct st20_tx_ops* ops) {
struct st_tx_video_session_impl* s;
int quota_mbs, ret;
uint64_t bps;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down Expand Up @@ -3999,6 +3996,10 @@ st20_tx_handle st20_tx_create(mtl_handle mt, struct st20_tx_ops* ops) {
}
}

enum mtl_port port = mt_port_by_name(impl, ops->port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST20_TX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST20_TX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down Expand Up @@ -4377,9 +4378,6 @@ st22_tx_handle st22_tx_create(mtl_handle mt, struct st22_tx_ops* ops) {
int quota_mbs, ret;
uint64_t bps;
struct st20_tx_ops st20_ops;
/* default use MTL_PORT_P */
int socket = mt_socket_id(impl, MTL_PORT_P);

notice("%s, start for %s\n", __func__, mt_string_safe(ops->name));

if (impl->type != MT_HANDLE_MAIN) {
Expand Down Expand Up @@ -4415,6 +4413,10 @@ st22_tx_handle st22_tx_create(mtl_handle mt, struct st22_tx_ops* ops) {
quota_mbs *= ops->num_port;
}

enum mtl_port port = mt_port_by_name(impl, ops->port[MTL_SESSION_PORT_P]);
if (port >= MTL_PORT_MAX) return NULL;
int socket = mt_socket_id(impl, port);

if (ops->flags & ST22_TX_FLAG_FORCE_NUMA) {
socket = ops->socket_id;
info("%s, ST22_TX_FLAG_FORCE_NUMA to socket %d\n", __func__, socket);
Expand Down

0 comments on commit 34a3a77

Please sign in to comment.