replace common qcom sources with samsung ones

This commit is contained in:
SaschaNes
2025-08-12 22:13:00 +02:00
parent ba24dcded9
commit 6f7753de11
5682 changed files with 2450203 additions and 103634 deletions

View File

@@ -0,0 +1,32 @@
cc_library_headers {
name: "librmnetctl_headers",
export_include_dirs: ["inc"],
vendor: true,
}
cc_defaults {
name: "librmnetctl_defaults",
cflags: [
"-Wall",
"-Werror",
],
header_libs: ["librmnetctl_headers"],
vendor: true,
}
cc_library_shared {
name: "librmnetctl",
header_libs: [
"qti_kernel_headers",
"device_kernel_headers",
],
defaults: ["librmnetctl_defaults"],
srcs: ["src/librmnetctl.c"],
}
cc_binary {
name: "rmnetcli",
shared_libs: ["librmnetctl"],
defaults: ["librmnetctl_defaults"],
srcs: ["cli/rmnetcli.c"],
}

View File

@@ -0,0 +1,9 @@
AM_CFLAGS = -Wall -Werror -Wundef -Wstrict-prototypes -Wno-trigraphs
AM_CFLAGS += -I./../inc
rmnetcli_SOURCES = rmnetcli.c
bin_PROGRAMS = rmnetcli
requiredlibs = ../src/librmnetctl.la
rmnetcli_LDADD = $(requiredlibs)
LOCAL_MODULE := librmnetctl
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1,511 @@
/******************************************************************************
R M N E T C L I . C
Copyright (c) 2013-2015, 2017-2021 The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/******************************************************************************
@file rmnetcli.c
@brief command line interface to expose rmnet control API's
DESCRIPTION
File containing implementation of the command line interface to expose the
rmnet control configuration .
******************************************************************************/
/*===========================================================================
INCLUDE FILES
===========================================================================*/
#include <sys/socket.h>
#include <stdint.h>
#include <linux/netlink.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include "rmnetcli.h"
#include "librmnetctl.h"
#define RMNET_MAX_STR_LEN 16
#define _RMNETCLI_CHECKNULL(X) do { if (!X) { \
print_rmnet_api_status(RMNETCTL_INVALID_ARG, RMNETCTL_CFG_FAILURE_NO_COMMAND); \
rtrmnet_ctl_deinit(handle); \
return RMNETCTL_INVALID_ARG; \
} } while (0);
#define _STRTOUI32(X) (uint32_t)strtoul(X, NULL, 0)
#define _STRTOUI16(X) (uint16_t)strtoul(X, NULL, 0)
#define _STRTOUI8(X) (uint8_t)strtoul(X, NULL, 0)
#define _STRTOI32(X) (int32_t)strtol(X, NULL, 0)
#define _5TABS "\n\t\t\t\t\t"
#define _2TABS "\n\t\t"
/*!
* @brief Contains a list of error message from CLI
*/
char rmnetcfg_error_code_text
[RMNETCFG_TOTAL_ERR_MSGS][RMNETCTL_ERR_MSG_SIZE] = {
"Help option Specified",
"ERROR: No\\Invalid command was specified\n",
"ERROR: Could not allocate buffer for Egress device\n"
};
/*!
* @brief Method to display the syntax for the commands
* @details Displays the syntax and usage for the commands
* @param void
* @return void
*/
static void rmnet_api_usage(void)
{
printf("RmNet API Usage:\n\n");
printf("rmnetcli help Displays this help\n");
printf("\n");
printf("**************************\n");
printf("RmNet RTM_NETLINK API Usage:\n\n");
printf("rmnetcli -n newlink <real dev> Add a vnd w/ newlink");
printf(_2TABS" <vnd> string - vnd device_name");
printf(_2TABS" <vnd id> int - new vnd id");
printf(_2TABS" [flags] int - starting flag config\n\n");
printf("rmnetcli -n changelink <real dev> Change a vnd's flags");
printf(_2TABS" <vnd> string - vnd device_name");
printf(_2TABS" <vnd id> int - new vnd id");
printf(_2TABS" <flags> int - new flag config\n\n");
printf("rmnetcli -n getlink <real dev> Get device config\n\n");
printf("rmnetcli -n dellink <real dev> Delete a vnd");
printf(_2TABS" by inputting dev name\n\n");
printf("rmnetcli -n bridgelink <real dev> Bridge a vnd and a dev");
printf(_2TABS" <vnd id> by specifying dev id and vnd id\n\n");
printf("rmnetcli -n uplinkparam <real dev> set uplink aggregation parameters");
printf(_2TABS" <vnd id> string - vnd device_name");
printf(_2TABS" <packet count> int - maximum packet count");
printf(_2TABS" <byte count> int - maximum byte count");
printf(_2TABS" <time limit> int - maximum time limit");
printf(_2TABS" <features> int - aggregation features\n\n");
printf("rmnetcli -n lluplinkparam <dev_name> set LL uplink aggregation parameters");
printf(_2TABS" <vnd id> string - vnd device_name");
printf(_2TABS" <packet count> int - maximum packet count");
printf(_2TABS" <byte count> int - maximum byte count");
printf(_2TABS" <time limit> int - maximum time limit");
printf(_2TABS" <features> int - aggregation features\n\n");
printf("rmnetcli -n flowactivate <real dev> activate a flow\n");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <bearer_id> int - bearer id\n\n");
printf(_2TABS" <flow id> int - flow id\n\n");
printf(_2TABS" <ip type> int - ip type\n\n");
printf(_2TABS" <handle> int - flow handle\n\n");
printf("rmnetcli -n flowdel <real dev> delete a flow\n");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <bearer_id> int - bearer id\n\n");
printf(_2TABS" <flow id> int - flow id\n\n");
printf(_2TABS" <ip type> int - ip type\n\n");
printf("rmnetcli -n flowcontrol <real dev>");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <bearer_id> int - bearer id\n\n");
printf(_2TABS" <seq> int - sequence\n\n");
printf(_2TABS" <grant size> int - grant size\n\n");
printf(_2TABS" <ack> int - ack\n\n");
printf("rmnetcli -n systemup <real dev>\n");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <instance> int - bearer id\n\n");
printf(_2TABS" <eptype> int - ep type\n\n");
printf(_2TABS" <iface_id> int - iface id\n\n");
printf(_2TABS" <flags> int - flags\n\n");
printf("rmnetcli -n systemdown <real dev> <vnd name> <instance>\n\n ");
printf("rmnetcli -n qmiscale <real dev> set ACK scale factor\n\n");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <scale> int - scale factor\n\n");
printf("rmnetcli -n wdafreq <real dev> set powersave poll freq\n\n");
printf(_2TABS" <vnd_name> string - vnd device name\n\n");
printf(_2TABS" <freq> int - frequency\n\n");
printf("rmnetcli -n channelswitch <real dev> change underlying transport channel for bearers");
printf(_2TABS" <vnd_name> string - vnd device name");
printf(_2TABS" <switch type> =0: from LL, !=0: to LL");
printf(_2TABS" <flags> masks. 1: wait for completion");
printf(_2TABS" <bearer id list> int - list of bearer ids to switch\n");
}
static void print_rmnetctl_lib_errors(uint16_t error_number)
{
if ((error_number > RMNETCTL_API_SUCCESS) &&
(error_number < RMNETCTL_API_ERR_ENUM_LENGTH)) {
printf("%s", rmnetctl_error_code_text[error_number]);
}
if ((error_number >= RMNETCFG_ERR_NUM_START) &&
(error_number < RMNETCFG_ERR_NUM_START + RMNETCFG_TOTAL_ERR_MSGS)) {
printf("%s", rmnetcfg_error_code_text
[error_number - RMNETCFG_ERR_NUM_START]);
if ((error_number == RMNETCTL_CFG_SUCCESS_HELP_COMMAND) ||
(error_number == RMNETCTL_CFG_FAILURE_NO_COMMAND))
rmnet_api_usage();
}
}
/*!
* @brief Method to check the error numbers generated from API calls
* @details Displays the error messages based on each error code
* @param error_number Error number returned from the API and the CLI
* @return void
*/
static void print_rmnet_api_status(int return_code, uint16_t error_number)
{
if (return_code == RMNETCTL_SUCCESS)
printf("SUCCESS\n");
else if (return_code == RMNETCTL_LIB_ERR) {
printf("LIBRARY ");
print_rmnetctl_lib_errors(error_number);
} else if (return_code == RMNETCTL_KERNEL_ERR) {
if (error_number < RMNETCTL_API_ERR_ENUM_LENGTH)
printf("KERNEL ERROR: System or rmnet error %d\n",
error_number);
}
else if (return_code == RMNETCTL_INVALID_ARG)
printf("INVALID_ARG\n");
}
/*!
* @brief Wait for rmnet LL switch status
* @details Waits and displays LL switch status
* @param num_bearers Number of bearers to wait for
* @return RMNETCTL_SUCCESS if successful.
*/
static int rmnet_ll_wait_status(rmnetctl_hndl_t *hndl,
uint8_t num_bearers,
uint16_t *error_number)
{
struct rmnetctl_ll_ack ll_ack;
int return_code = RMNETCTL_SUCCESS;
printf("LL switch initiated, waiting for completion...\n");
printf("Bearer/Status/Channel:\n");
while (num_bearers--) {
return_code = rtrmnet_get_ll_ack(hndl, &ll_ack, error_number);
if (return_code != RMNETCTL_SUCCESS)
return return_code;
printf("%u | %u (%s) | %u (%s)\n",
ll_ack.bearer_id,
ll_ack.status_code,
rtrmnet_ll_status_to_text(
ll_ack.status_code),
ll_ack.current_ch,
ll_ack.current_ch ? "LL" : "Default");
}
return return_code;
}
/*!
* @brief Method to make the API calls
* @details Checks for each type of parameter and calls the appropriate
* function based on the number of parameters and parameter type
* @param argc Number of arguments which vary based on the commands
* @param argv Value of the arguments which vary based on the commands
* @return RMNETCTL_SUCCESS if successful. Relevant data might be printed
* based on the message type
* @return RMNETCTL_LIB_ERR if there was a library error. Error code will be
* printed
* @return RMNETCTL_KERNEL_ERR if there was a error in the kernel. Error code will be
* printed
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
static int rmnet_api_call(int argc, char *argv[])
{
struct rmnetctl_hndl_s *handle = NULL;
uint16_t error_number = RMNETCTL_CFG_FAILURE_NO_COMMAND;
int return_code = RMNETCTL_LIB_ERR;
if ((!argc) || (!*argv)) {
print_rmnet_api_status(RMNETCTL_LIB_ERR,
RMNETCTL_CFG_FAILURE_NO_COMMAND);
return RMNETCTL_LIB_ERR;
}
if (!strcmp(*argv, "help")) {
print_rmnet_api_status(RMNETCTL_LIB_ERR,
RMNETCTL_CFG_SUCCESS_HELP_COMMAND);
return RMNETCTL_LIB_ERR;
}
if (!strcmp(*argv, "-n")) {
return_code = rtrmnet_ctl_init(&handle, &error_number);
if (return_code != RMNETCTL_SUCCESS) {
print_rmnet_api_status(return_code, error_number);
return RMNETCTL_LIB_ERR;
}
error_number = RMNETCTL_CFG_FAILURE_NO_COMMAND;
return_code = RMNETCTL_LIB_ERR;
argv++;
argc--;
if ((!argc) || (!*argv)) {
print_rmnet_api_status(RMNETCTL_LIB_ERR,
RMNETCTL_CFG_FAILURE_NO_COMMAND);
return RMNETCTL_LIB_ERR;
}
if (!strcmp(*argv, "newlink")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
uint32_t flags = 0;
/* If optional flag was used pass it on*/
if (argv[4])
flags = _STRTOI32(argv[4]);
return_code = rtrmnet_ctl_newvnd(handle, argv[1],
argv[2],
&error_number,
_STRTOI32(argv[3]),
flags);
} else if (!strcmp(*argv, "changelink")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
return_code = rtrmnet_ctl_changevnd(handle, argv[1],
argv[2],
&error_number,
_STRTOI32(argv[3]),
_STRTOI32(argv[4]));
} else if (!strcmp(*argv, "getlink")) {
_RMNETCLI_CHECKNULL(argv[1]);
uint32_t flags = 0;
uint16_t mux_id = 0;
uint8_t agg_count = 0;
uint16_t agg_size = 0;
uint32_t agg_time = 0;
uint8_t features = 0;
return_code = rtrmnet_ctl_getvnd(handle, argv[1],
&error_number,
&mux_id, &flags,
&agg_count, &agg_size,
&agg_time, &features);
if (return_code == RMNETCTL_API_SUCCESS) {
printf("Configuration for device %s:\n", argv[1]);
printf("\tMux id: %d\n", mux_id);
printf("\tData format: 0x%04x\n", flags);
printf("\tUplink Aggregation parameters:\n");
printf("\t\tPacket limit: %d\n", agg_count);
printf("\t\tByte limit: %d\n", agg_size);
printf("\t\tTime limit (ns): %d\n", agg_time);
printf("\t\tFeatures : 0x%02x\n", features);
}
} else if (!strcmp(*argv, "dellink")) {
_RMNETCLI_CHECKNULL(argv[1]);
return_code = rtrmnet_ctl_delvnd(handle, argv[1],
&error_number);
} else if (!strcmp(*argv, "bridge")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
return_code = rtrmnet_ctl_bridgevnd(handle, argv[1],
argv[2],
&error_number);
} else if (!strcmp(*argv, "uplinkparam")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
_RMNETCLI_CHECKNULL(argv[6]);
return_code = rtrmnet_set_uplink_aggregation_params(
handle, argv[1], argv[2], _STRTOUI8(argv[3]),
_STRTOUI16(argv[4]), _STRTOUI32(argv[5]),
_STRTOUI8(argv[6]), &error_number);
} else if (!strcmp(*argv, "lluplinkparam")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
_RMNETCLI_CHECKNULL(argv[6]);
return_code = rtrmnet_set_ll_uplink_aggregation_params(
handle, argv[1], argv[2], _STRTOUI8(argv[3]),
_STRTOUI16(argv[4]), _STRTOUI32(argv[5]),
_STRTOUI8(argv[6]), &error_number);
}
else if (!strcmp(*argv, "flowactivate")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
_RMNETCLI_CHECKNULL(argv[6]);
return_code = rtrmnet_activate_flow(handle, argv[1], argv[2],
_STRTOUI8(argv[3]),
_STRTOI32(argv[4]),
_STRTOUI32(argv[5]),
_STRTOUI32(argv[6]),
&error_number);
} else if (!strcmp(*argv, "flowdel")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
return_code = rtrmnet_delete_flow(handle, argv[1], argv[2],
_STRTOUI8(argv[3]),
_STRTOUI32(argv[4]),
_STRTOI32(argv[5]),
&error_number);
} else if (!strcmp(*argv, "flowcontrol")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
_RMNETCLI_CHECKNULL(argv[6]);
return_code = rtrmnet_control_flow(handle, argv[1], argv[2],
_STRTOUI8(argv[3]),
_STRTOUI32(argv[4]),
_STRTOUI16(argv[5]),
_STRTOUI8(argv[6]),
&error_number);
} else if (!strcmp(*argv, "systemup")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
_RMNETCLI_CHECKNULL(argv[5]);
_RMNETCLI_CHECKNULL(argv[6]);
return_code = rtrmnet_flow_state_up(handle, argv[1], argv[2],
_STRTOUI32(argv[3]),
_STRTOUI32(argv[4]),
_STRTOUI32(argv[5]),
_STRTOUI32(argv[6]),
&error_number);
} else if (!strcmp(*argv, "systemdown")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
return_code = rtrmnet_flow_state_down(handle, argv[1], argv[2],
_STRTOUI32(argv[3]),
&error_number);
} else if (!strcmp(*argv, "qmiscale")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
return_code = rtrmnet_set_qmi_scale(handle, argv[1], argv[2],
_STRTOUI32(argv[3]),
&error_number);
} else if (!strcmp(*argv, "wdafreq")) {
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
return_code = rtrmnet_set_wda_freq(handle, argv[1], argv[2],
_STRTOUI32(argv[3]),
&error_number);
} else if (!strcmp(*argv, "channelswitch")) {
uint32_t ll_flags;
uint8_t *bearers;
int num_bearers = argc - 5;
int i;
_RMNETCLI_CHECKNULL(argv[1]);
_RMNETCLI_CHECKNULL(argv[2]);
_RMNETCLI_CHECKNULL(argv[3]);
_RMNETCLI_CHECKNULL(argv[4]);
/* Force at least one bearer to be provided */
_RMNETCLI_CHECKNULL(argv[5]);
bearers = calloc(sizeof(uint8_t), num_bearers);
if (!bearers) {
print_rmnet_api_status(RMNETCTL_INVALID_ARG,
RMNETCTL_CFG_FAILURE_NO_COMMAND);
rtrmnet_ctl_deinit(handle);
return RMNETCTL_INVALID_ARG;
}
for (i = 0; i < num_bearers; i++)
bearers[i] = _STRTOUI8(argv[5 + i]);
ll_flags = _STRTOUI32(argv[4]);
return_code = rtrmnet_change_bearer_channel(handle,
argv[1],
argv[2],
_STRTOUI8(argv[3]),
ll_flags,
num_bearers,
bearers,
&error_number);
free(bearers);
if (return_code == RMNETCTL_SUCCESS &&
(ll_flags & RMNETCTL_LL_MASK_ACK))
return_code = rmnet_ll_wait_status(
handle, num_bearers, &error_number);
}
goto end;
}
end:
print_rmnet_api_status(return_code, error_number);
rtrmnet_ctl_deinit(handle);
return return_code;
}
/*!
* @brief Method which serves as en entry point to the rmnetcli function
* @details Entry point for the RmNet Netlink API. This is the command line
* interface for the RmNet API
* @param argc Number of arguments which vary based on the commands
* @param argv Value of the arguments which vary based on the commands
* @return RMNETCTL_SUCCESS if successful. Relevant data might be printed
* based on the message type
* @return RMNETCTL_LIB_ERR if there was a library error. Error code will be
* printed
* @return RMNETCTL_KERNEL_ERR if there was a error in the kernel. Error code will be
* printed
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int main(int argc, char *argv[])
{
argc--;
argv++;
return rmnet_api_call(argc, argv);
}

View File

@@ -0,0 +1,61 @@
/******************************************************************************
R M N E T C L I . H
Copyright (c) 2013, 2015 The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/******************************************************************************
@file rmnetcli.h
@brief headers for the command line interface to expose rmnet control API's
DESCRIPTION
Header file containing definition for the command line interface to expose
rmnet control API's
******************************************************************************/
#ifndef RMNETCLI_H
#define RMNETCLI_H
/* Print the help for the commands since the help flag was used. */
#define RMNETCTL_CFG_SUCCESS_HELP_COMMAND 100
/* No/invalid API call was specified. So return an error. */
#define RMNETCTL_CFG_FAILURE_NO_COMMAND 101
/* The buffer for egress device name was NULL */
#define RMNETCTL_CFG_FAILURE_EGRESS_DEV_NAME_NULL 102
/* This should always be the value of the starting element */
#define RMNETCFG_ERR_NUM_START 100
/* This should always be the total number of error message from CLI */
#define RMNETCFG_TOTAL_ERR_MSGS 3
#endif /* not defined RMNETCLI_H */

View File

@@ -0,0 +1,406 @@
/******************************************************************************
L I B R M N E T C T L . H
Copyright (c) 2013-2015, 2017-2019, 2021 The Linux Foundation.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/*!
* @file librmnetctl.h
* @brief rmnet control API's header file
*/
#ifndef LIBRMNETCTL_H
#define LIBRMNETCTL_H
/* RMNET API succeeded */
#define RMNETCTL_SUCCESS 0
/* RMNET API encountered an error while executing within the library. Check the
* error code in this case */
#define RMNETCTL_LIB_ERR 1
/* RMNET API encountered an error while executing in the kernel. Check the
* error code in this case */
#define RMNETCTL_KERNEL_ERR 2
/* RMNET API encountered an error because of invalid arguments*/
#define RMNETCTL_INVALID_ARG 3
/* Flag to associate a network device*/
#define RMNETCTL_DEVICE_ASSOCIATE 1
/* Flag to unassociate a network device*/
#define RMNETCTL_DEVICE_UNASSOCIATE 0
/* Flag to create a new virtual network device*/
#define RMNETCTL_NEW_VND 1
/* Flag to free a new virtual network device*/
#define RMNETCTL_FREE_VND 0
/* Flag to add a new flow*/
#define RMNETCTL_ADD_FLOW 1
/* Flag to delete an existing flow*/
#define RMNETCTL_DEL_FLOW 0
enum rmnetctl_error_codes_e {
/* API succeeded. This should always be the first element. */
RMNETCTL_API_SUCCESS = 0,
RMNETCTL_API_FIRST_ERR = 1,
/* API failed because not enough memory to create buffer to send
* message */
RMNETCTL_API_ERR_REQUEST_INVALID = RMNETCTL_API_FIRST_ERR,
/* API failed because not enough memory to create buffer for the
* response message */
RMNETCTL_API_ERR_RESPONSE_INVALID = 2,
/* API failed because could not send the message to kernel */
RMNETCTL_API_ERR_MESSAGE_SEND = 3,
/* API failed because could not receive message from the kernel */
RMNETCTL_API_ERR_MESSAGE_RECEIVE = 4,
RMNETCTL_INIT_FIRST_ERR = 5,
/* Invalid process id. So return an error. */
RMNETCTL_INIT_ERR_PROCESS_ID = RMNETCTL_INIT_FIRST_ERR,
/* Invalid socket descriptor id. So return an error. */
RMNETCTL_INIT_ERR_NETLINK_FD = 6,
/* Could not bind the socket to the Netlink file descriptor */
RMNETCTL_INIT_ERR_BIND = 7,
/* Invalid user id. Only root has access to this function. (NA) */
RMNETCTL_INIT_ERR_INVALID_USER = 8,
RMNETCTL_API_SECOND_ERR = 9,
/* API failed because the RmNet handle for the transaction was NULL */
RMNETCTL_API_ERR_HNDL_INVALID = RMNETCTL_API_SECOND_ERR,
/* API failed because the request buffer for the transaction was NULL */
RMNETCTL_API_ERR_REQUEST_NULL = 10,
/* API failed because the response buffer for the transaction was NULL*/
RMNETCTL_API_ERR_RESPONSE_NULL = 11,
/* API failed because the request and response type do not match*/
RMNETCTL_API_ERR_MESSAGE_TYPE = 12,
/* API failed because the return type is invalid */
RMNETCTL_API_ERR_RETURN_TYPE = 13,
/* API failed because the string was truncated */
RMNETCTL_API_ERR_STRING_TRUNCATION = 14,
/* These error are 1-to-1 with rmnet_data config errors in rmnet_data.h
for each conversion.
please keep the enums synced.
*/
RMNETCTL_KERNEL_FIRST_ERR = 15,
/* No error */
RMNETCTL_KERNEL_ERROR_NO_ERR = RMNETCTL_KERNEL_FIRST_ERR,
/* Invalid / unsupported message */
RMNETCTL_KERNEL_ERR_UNKNOWN_MESSAGE = 16,
/* Internal problem in the kernel module */
RMNETCTL_KERNEL_ERR_INTERNAL = 17,
/* Kernel is temporarily out of memory */
RMNETCTL_KERNEL_ERR_OUT_OF_MEM = 18,
/* Device already exists / Still in use */
RMETNCTL_KERNEL_ERR_DEVICE_IN_USE = 19,
/* Invalid request / Unsupported scenario */
RMNETCTL_KERNEL_ERR_INVALID_REQUEST = 20,
/* Device doesn't exist */
RMNETCTL_KERNEL_ERR_NO_SUCH_DEVICE = 21,
/* One or more of the arguments is invalid */
RMNETCTL_KERNEL_ERR_BAD_ARGS = 22,
/* Egress device is invalid */
RMNETCTL_KERNEL_ERR_BAD_EGRESS_DEVICE = 23,
/* TC handle is full */
RMNETCTL_KERNEL_ERR_TC_HANDLE_FULL = 24,
RMNETCTL_API_THIRD_ERR = 25,
/* Failed to copy data into netlink message */
RMNETCTL_API_ERR_RTA_FAILURE = RMNETCTL_API_THIRD_ERR,
/* This should always be the last element */
RMNETCTL_API_ERR_ENUM_LENGTH
};
#define RMNETCTL_ERR_MSG_SIZE 100
/*!
* @brief Contains a list of error message from API
*/
#define RMNETCTL_LL_MASK_ACK 1
#define RMNETCTL_LL_MASK_RETRY 2
enum rmnetctl_ll_status_e {
LL_STATUS_ERROR = 0,
LL_STATUS_SUCCESS = 1,
LL_STATUS_DEFAULT = 2,
LL_STATUS_LL = 3,
LL_STATUS_TEMP_FAIL = 4,
LL_STATUS_PERM_FAIL = 5,
LL_STATUS_NO_EFFECT = 0xFD,
LL_STATUS_TIMEOUT = 0xFE
};
struct rmnetctl_ll_ack
{
uint8_t bearer_id;
uint8_t status_code;
uint8_t current_ch;
};
/*===========================================================================
DEFINITIONS AND DECLARATIONS
===========================================================================*/
typedef struct rmnetctl_hndl_s rmnetctl_hndl_t;
/* @brief Public API to initialize the RTM_NETLINK RMNET control driver
* @details Allocates memory for the RmNet handle. Creates and binds to a
* netlink socket if successful
* @param **rmnetctl_hndl_t_val RmNet handle to be initialized
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_ctl_init(rmnetctl_hndl_t **hndl, uint16_t *error_code);
/* @brief Public API to clean up the RTM_NETLINK RmNeT control handle
* @details Close the socket and free the RmNet handle
* @param *rmnetctl_hndl_t_val RmNet handle to be initialized
* @return void
*/
int rtrmnet_ctl_deinit(rmnetctl_hndl_t *hndl);
/* @brief Public API to create a new virtual device node
* @details Message type is RTM_NEWLINK
* @param hndl RmNet handle for the Netlink message
* @param dev_name Device name new node will be connected to
* @param vnd_name Name of virtual device to be created
* @param error_code Status code of this operation returned from the kernel
* @param index Index node will have
* @param flagconfig Flag configuration device will have
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_ctl_newvnd(rmnetctl_hndl_t *hndl, char *devname, char *vndname,
uint16_t *error_code, uint8_t index,
uint32_t flagconfig);
/* @brief Public API to delete a virtual device node
* @details Message type is RTM_DELLINK
* @param hndl RmNet handle for the Netlink message
* @param vnd_name Name of virtual device to be deleted
* @param error_code Status code of this operation returned from the kernel
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_ctl_delvnd(rmnetctl_hndl_t *hndl, char *vndname,
uint16_t *error_code);
/* @brief Public API to change flag's of a virtual device node
* @details Message type is RTM_NEWLINK
* @param hndl RmNet handle for the Netlink message
* @param dev_name Name of device node is connected to
* @param vnd_name Name of virtual device to be changed
* @param error_code Status code of this operation returned from the kernel
* @param flagconfig New flag config vnd should have
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_ctl_changevnd(rmnetctl_hndl_t *hndl, char *devname, char *vndname,
uint16_t *error_code, uint8_t index,
uint32_t flagconfig);
/* @brief Public API to retrieve configuration of a virtual device node
* @details Message type is RTM_GETLINK
* @param hndl RmNet handle for the Netlink message
* @param vndname Name of virtual device to query
* @param error_code Status code of this operation returned from the kernel
* @param mux_id Where to store the value of the node's mux id
* @param flagconfig Where to store the value of the node's data format flags
* @param agg_count Where to store the value of the node's maximum packet count
* for uplink aggregation
* @param agg_size Where to store the value of the node's maximum byte count
* for uplink aggregation
* @param agg_time Where to store the value of the node's maximum time limit
* for uplink aggregation
* @param agg_time Where to store the value of the node's features
* for uplink aggregation
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARF if invalid arguments were passed to the API
*/
int rtrmnet_ctl_getvnd(rmnetctl_hndl_t *hndl, char *vndname,
uint16_t *error_code, uint16_t *mux_id,
uint32_t *flagconfig, uint8_t *agg_count,
uint16_t *agg_size, uint32_t *agg_time,
uint8_t *features);
/* @brief Public API to bridge a vnd and device
* @details Message type is RTM_NEWLINK
* @param hndl RmNet handle for the Netlink message
* @param dev_name device to bridge msg will be sent to
* @param vnd_name vnd name of device that will be dev_name's master
* @param error_code Status code of this operation returned from the kernel
* @return RMNETCTL_SUCCESS if successful
* @return RMNETCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_ctl_bridgevnd(rmnetctl_hndl_t *hndl, char *devname, char *vndname,
uint16_t *error_code);
/* @brief Public API to configure the uplink aggregation parameters
* used by the RmNet driver
* @details Message type is RMN_NEWLINK
* @param hndl RmNet handle for the Netlink message
* @param devname Name of device node is connected to
* @param vndname Name of virtual device
* @param packet_count Maximum number of packets to aggregate
* @param byte_count Maximum number of bytes to aggregate
* @param time_limit Maximum time to aggregate
* @param error_code Status code of this operation returned from the kernel
* @return RMNETCTL_SUCCESS if successful
* @return RMENTCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_set_uplink_aggregation_params(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t packet_count,
uint16_t byte_count,
uint32_t time_limit,
uint8_t features,
uint16_t *error_code);
/* @brief Public API to configure the uplink aggregation parameters
* used by the RmNet driver for the Low Latency channel
* @details Message type is RMN_NEWLINK
* @param hndl RmNet handle for the Netlink message
* @param devname Name of device node is connected to
* @param vndname Name of virtual device
* @param packet_count Maximum number of packets to aggregate
* @param byte_count Maximum number of bytes to aggregate
* @param time_limit Maximum time to aggregate
* @param error_code Status code of this operation returned from the kernel
* @return RMNETCTL_SUCCESS if successful
* @return RMENTCTL_LIB_ERR if there was a library error. Check error_code
* @return RMNETCTL_KERNEL_ERR if there was an error in the kernel.
* Check error_code
* @return RMNETCTL_INVALID_ARG if invalid arguments were passed to the API
*/
int rtrmnet_set_ll_uplink_aggregation_params(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t packet_count,
uint16_t byte_count,
uint32_t time_limit,
uint8_t features,
uint16_t *error_code);
int rtrmnet_activate_flow(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t bearer_id,
uint32_t flow_id,
int ip_type,
uint32_t tcm_handle,
uint16_t *error_code);
int rtrmnet_delete_flow(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t bearer_id,
uint32_t flow_id,
int ip_type,
uint16_t *error_code);
int rtrmnet_control_flow(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t bearer_id,
uint16_t sequence,
uint32_t grantsize,
uint8_t ack,
uint16_t *error_code);
int rtrmnet_flow_state_down(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint32_t instance,
uint16_t *error_code);
int rtrmnet_flow_state_up(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint32_t instance,
uint32_t ep_type,
uint32_t ifaceid,
int flags,
uint16_t *error_code);
int rtrmnet_set_qmi_scale(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint32_t scale,
uint16_t *error_code);
int rtrmnet_set_wda_freq(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint32_t freq,
uint16_t *error_code);
int rtrmnet_change_bearer_channel(rmnetctl_hndl_t *hndl,
char *devname,
char *vndname,
uint8_t switch_type,
uint32_t flags,
uint8_t num_bearers,
uint8_t *bearers,
uint16_t *error_code);
int rtrmnet_get_ll_ack(rmnetctl_hndl_t *hndl,
struct rmnetctl_ll_ack *ll_ack,
uint16_t *error_code);
const char *rtrmnet_ll_status_to_text(uint8_t status);
#endif /* not defined LIBRMNETCTL_H */

View File

@@ -0,0 +1,66 @@
/******************************************************************************
L I B R M N E T C T L _ H N D L. H
Copyright (c) 2013, 2015, 2021 The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/*!
* @file librmnetctl_hndl.h
* @brief rmnet control API's handle file
*/
#ifndef LIBRMNETCTL_HNDL_H
#define LIBRMNETCTL_HNDL_H
/*===========================================================================
DEFINITIONS AND DECLARATIONS
===========================================================================*/
/*!
* @brief Structure for RMNET control handles. A rmnet hndl contains the caller
* process id, the transaction id which is initialized to 0 for each new
* initialized handle and the netlink file descriptor for this handle.
* @var pid process id to be used for the netlink message
* @var transaction_id message number for debugging
* @var netlink_fd netlink file descriptor to be used
* @var src_addr source socket address properties for this message
* @var dest_addr destination socket address properties for this message
*/
struct rmnetctl_hndl_s {
uint32_t pid;
uint32_t transaction_id;
int netlink_fd;
struct sockaddr_nl src_addr, dest_addr;
struct rmnetctl_hndl_s *llc_hndl;
};
#endif /* not defined LIBRMNETCTL_HNDL_H */

View File

@@ -0,0 +1,16 @@
AM_CFLAGS = -Wall -Werror -Wundef -Wstrict-prototypes -Wno-trigraphs
AM_CFLAGS += -I./../inc
librmnetctl_la_C = @C@
librmnetctl_la_SOURCES = librmnetctl.c
common_CFLAGS = -DUSE_GLIB @GLIB_CFLAGS@
common_LDFLAGS = -lpthread -lrt @GLIB_LIBS@
librmnetctl_la_CFLAGS := $(AM_CFLAGS) $(common_CFLAGS)
librmnetctl_la_LDFLAGS := -shared $(common_LDFLAGS)
library_includedir = $(pkgincludedir)
library_include_HEADERS = ./../inc/librmnetctl.h
lib_LTLIBRARIES = librmnetctl.la

File diff suppressed because it is too large Load Diff