123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506 |
- /*
- * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #include <net/pkt_sched.h>
- #include "rmnet_qmi.h"
- #include "qmi_rmnet.h"
- #include "dfc_defs.h"
- #define CREATE_TRACE_POINTS
- #include "dfc.h"
- struct dfc_qmap_header {
- u8 pad_len:6;
- u8 reserved_bit:1;
- u8 cd_bit:1;
- u8 mux_id;
- __be16 pkt_len;
- } __aligned(1);
- struct dfc_ack_cmd {
- struct dfc_qmap_header header;
- u8 command_name;
- u8 cmd_type:2;
- u8 reserved:6;
- u16 reserved2;
- u32 transaction_id;
- u8 ver:2;
- u8 reserved3:6;
- u8 type:2;
- u8 reserved4:6;
- u16 dfc_seq;
- u8 reserved5[3];
- u8 bearer_id;
- } __aligned(1);
- static void dfc_svc_init(struct work_struct *work);
- /* **************************************************** */
- #define DFC_SERVICE_ID_V01 0x4E
- #define DFC_SERVICE_VERS_V01 0x01
- #define DFC_TIMEOUT_JF msecs_to_jiffies(1000)
- #define QMI_DFC_BIND_CLIENT_REQ_V01 0x0020
- #define QMI_DFC_BIND_CLIENT_RESP_V01 0x0020
- #define QMI_DFC_BIND_CLIENT_REQ_V01_MAX_MSG_LEN 11
- #define QMI_DFC_BIND_CLIENT_RESP_V01_MAX_MSG_LEN 7
- #define QMI_DFC_INDICATION_REGISTER_REQ_V01 0x0001
- #define QMI_DFC_INDICATION_REGISTER_RESP_V01 0x0001
- #define QMI_DFC_INDICATION_REGISTER_REQ_V01_MAX_MSG_LEN 8
- #define QMI_DFC_INDICATION_REGISTER_RESP_V01_MAX_MSG_LEN 7
- #define QMI_DFC_FLOW_STATUS_IND_V01 0x0022
- #define QMI_DFC_TX_LINK_STATUS_IND_V01 0x0024
- #define QMI_DFC_GET_FLOW_STATUS_REQ_V01 0x0023
- #define QMI_DFC_GET_FLOW_STATUS_RESP_V01 0x0023
- #define QMI_DFC_GET_FLOW_STATUS_REQ_V01_MAX_MSG_LEN 20
- #define QMI_DFC_GET_FLOW_STATUS_RESP_V01_MAX_MSG_LEN 543
- struct dfc_bind_client_req_msg_v01 {
- u8 ep_id_valid;
- struct data_ep_id_type_v01 ep_id;
- };
- struct dfc_bind_client_resp_msg_v01 {
- struct qmi_response_type_v01 resp;
- };
- struct dfc_indication_register_req_msg_v01 {
- u8 report_flow_status_valid;
- u8 report_flow_status;
- u8 report_tx_link_status_valid;
- u8 report_tx_link_status;
- };
- struct dfc_indication_register_resp_msg_v01 {
- struct qmi_response_type_v01 resp;
- };
- static struct qmi_elem_info dfc_qos_id_type_v01_ei[] = {
- {
- .data_type = QMI_UNSIGNED_4_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u32),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct dfc_qos_id_type_v01,
- qos_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_SIGNED_4_BYTE_ENUM,
- .elem_len = 1,
- .elem_size = sizeof(enum dfc_ip_type_enum_v01),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct dfc_qos_id_type_v01,
- ip_type),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_flow_status_info_type_v01_ei[] = {
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- subs_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- mux_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- bearer_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_4_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u32),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- num_bytes),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_2_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u16),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- seq_num),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- qos_ids_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = DFC_MAX_QOS_ID_V01,
- .elem_size = sizeof(struct dfc_qos_id_type_v01),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_flow_status_info_type_v01,
- qos_ids),
- .ei_array = dfc_qos_id_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_ancillary_info_type_v01_ei[] = {
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_ancillary_info_type_v01,
- subs_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_ancillary_info_type_v01,
- mux_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_ancillary_info_type_v01,
- bearer_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_4_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u32),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_ancillary_info_type_v01,
- reserved),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- struct dfc_get_flow_status_req_msg_v01 {
- u8 bearer_id_list_valid;
- u8 bearer_id_list_len;
- u8 bearer_id_list[DFC_MAX_BEARERS_V01];
- };
- struct dfc_get_flow_status_resp_msg_v01 {
- struct qmi_response_type_v01 resp;
- u8 flow_status_valid;
- u8 flow_status_len;
- struct dfc_flow_status_info_type_v01 flow_status[DFC_MAX_BEARERS_V01];
- };
- struct dfc_svc_ind {
- struct list_head list;
- u16 msg_id;
- union {
- struct dfc_flow_status_ind_msg_v01 dfc_info;
- struct dfc_tx_link_status_ind_msg_v01 tx_status;
- } d;
- };
- static struct qmi_elem_info dfc_bind_client_req_msg_v01_ei[] = {
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct dfc_bind_client_req_msg_v01,
- ep_id_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = 1,
- .elem_size = sizeof(struct data_ep_id_type_v01),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct dfc_bind_client_req_msg_v01,
- ep_id),
- .ei_array = data_ep_id_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_bind_client_resp_msg_v01_ei[] = {
- {
- .data_type = QMI_STRUCT,
- .elem_len = 1,
- .elem_size = sizeof(struct qmi_response_type_v01),
- .array_type = NO_ARRAY,
- .tlv_type = 0x02,
- .offset = offsetof(struct dfc_bind_client_resp_msg_v01,
- resp),
- .ei_array = qmi_response_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_indication_register_req_msg_v01_ei[] = {
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_indication_register_req_msg_v01,
- report_flow_status_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_indication_register_req_msg_v01,
- report_flow_status),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x11,
- .offset = offsetof(struct
- dfc_indication_register_req_msg_v01,
- report_tx_link_status_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x11,
- .offset = offsetof(struct
- dfc_indication_register_req_msg_v01,
- report_tx_link_status),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_indication_register_resp_msg_v01_ei[] = {
- {
- .data_type = QMI_STRUCT,
- .elem_len = 1,
- .elem_size = sizeof(struct qmi_response_type_v01),
- .array_type = NO_ARRAY,
- .tlv_type = 0x02,
- .offset = offsetof(struct
- dfc_indication_register_resp_msg_v01,
- resp),
- .ei_array = qmi_response_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_flow_status_ind_v01_ei[] = {
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- flow_status_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- flow_status_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = DFC_MAX_BEARERS_V01,
- .elem_size = sizeof(struct
- dfc_flow_status_info_type_v01),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- flow_status),
- .ei_array = dfc_flow_status_info_type_v01_ei,
- },
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x11,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- eod_ack_reqd_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x11,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- eod_ack_reqd),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x12,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- ancillary_info_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x12,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- ancillary_info_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = DFC_MAX_BEARERS_V01,
- .elem_size = sizeof(struct
- dfc_ancillary_info_type_v01),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x12,
- .offset = offsetof(struct
- dfc_flow_status_ind_msg_v01,
- ancillary_info),
- .ei_array = dfc_ancillary_info_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_get_flow_status_req_msg_v01_ei[] = {
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_req_msg_v01,
- bearer_id_list_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_req_msg_v01,
- bearer_id_list_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = DFC_MAX_BEARERS_V01,
- .elem_size = sizeof(u8),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_req_msg_v01,
- bearer_id_list),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_get_flow_status_resp_msg_v01_ei[] = {
- {
- .data_type = QMI_STRUCT,
- .elem_len = 1,
- .elem_size = sizeof(struct qmi_response_type_v01),
- .array_type = NO_ARRAY,
- .tlv_type = 0x02,
- .offset = offsetof(struct
- dfc_get_flow_status_resp_msg_v01,
- resp),
- .ei_array = qmi_response_type_v01_ei,
- },
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_resp_msg_v01,
- flow_status_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_resp_msg_v01,
- flow_status_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = DFC_MAX_BEARERS_V01,
- .elem_size = sizeof(struct
- dfc_flow_status_info_type_v01),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_get_flow_status_resp_msg_v01,
- flow_status),
- .ei_array = dfc_flow_status_info_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_bearer_info_type_v01_ei[] = {
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_bearer_info_type_v01,
- subs_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_bearer_info_type_v01,
- mux_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_bearer_info_type_v01,
- bearer_id),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_SIGNED_4_BYTE_ENUM,
- .elem_len = 1,
- .elem_size = sizeof(enum dfc_ip_type_enum_v01),
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- .offset = offsetof(struct
- dfc_bearer_info_type_v01,
- ip_type),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static struct qmi_elem_info dfc_tx_link_status_ind_v01_ei[] = {
- {
- .data_type = QMI_UNSIGNED_1_BYTE,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x01,
- .offset = offsetof(struct
- dfc_tx_link_status_ind_msg_v01,
- tx_status),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_OPT_FLAG,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_tx_link_status_ind_msg_v01,
- bearer_info_valid),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_DATA_LEN,
- .elem_len = 1,
- .elem_size = sizeof(u8),
- .array_type = NO_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_tx_link_status_ind_msg_v01,
- bearer_info_len),
- .ei_array = NULL,
- },
- {
- .data_type = QMI_STRUCT,
- .elem_len = DFC_MAX_BEARERS_V01,
- .elem_size = sizeof(struct
- dfc_bearer_info_type_v01),
- .array_type = VAR_LEN_ARRAY,
- .tlv_type = 0x10,
- .offset = offsetof(struct
- dfc_tx_link_status_ind_msg_v01,
- bearer_info),
- .ei_array = dfc_bearer_info_type_v01_ei,
- },
- {
- .data_type = QMI_EOTI,
- .array_type = NO_ARRAY,
- .tlv_type = QMI_COMMON_TLV_TYPE,
- },
- };
- static int
- dfc_bind_client_req(struct qmi_handle *dfc_handle,
- struct sockaddr_qrtr *ssctl, struct svc_info *svc)
- {
- struct dfc_bind_client_resp_msg_v01 *resp;
- struct dfc_bind_client_req_msg_v01 *req;
- struct qmi_txn txn;
- int ret;
- req = kzalloc(sizeof(*req), GFP_ATOMIC);
- if (!req)
- return -ENOMEM;
- resp = kzalloc(sizeof(*resp), GFP_ATOMIC);
- if (!resp) {
- kfree(req);
- return -ENOMEM;
- }
- ret = qmi_txn_init(dfc_handle, &txn,
- dfc_bind_client_resp_msg_v01_ei, resp);
- if (ret < 0) {
- pr_err("%s() Failed init for response, err: %d\n",
- __func__, ret);
- goto out;
- }
- req->ep_id_valid = 1;
- req->ep_id.ep_type = svc->ep_type;
- req->ep_id.iface_id = svc->iface_id;
- ret = qmi_send_request(dfc_handle, ssctl, &txn,
- QMI_DFC_BIND_CLIENT_REQ_V01,
- QMI_DFC_BIND_CLIENT_REQ_V01_MAX_MSG_LEN,
- dfc_bind_client_req_msg_v01_ei, req);
- if (ret < 0) {
- qmi_txn_cancel(&txn);
- pr_err("%s() Failed sending request, err: %d\n",
- __func__, ret);
- goto out;
- }
- ret = qmi_txn_wait(&txn, DFC_TIMEOUT_JF);
- if (ret < 0) {
- pr_err("%s() Response waiting failed, err: %d\n",
- __func__, ret);
- } else if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
- pr_err("%s() Request rejected, result: %d, err: %d\n",
- __func__, resp->resp.result, resp->resp.error);
- ret = -resp->resp.result;
- }
- out:
- kfree(resp);
- kfree(req);
- return ret;
- }
- static int
- dfc_indication_register_req(struct qmi_handle *dfc_handle,
- struct sockaddr_qrtr *ssctl, u8 reg)
- {
- struct dfc_indication_register_resp_msg_v01 *resp;
- struct dfc_indication_register_req_msg_v01 *req;
- struct qmi_txn txn;
- int ret;
- req = kzalloc(sizeof(*req), GFP_ATOMIC);
- if (!req)
- return -ENOMEM;
- resp = kzalloc(sizeof(*resp), GFP_ATOMIC);
- if (!resp) {
- kfree(req);
- return -ENOMEM;
- }
- ret = qmi_txn_init(dfc_handle, &txn,
- dfc_indication_register_resp_msg_v01_ei, resp);
- if (ret < 0) {
- pr_err("%s() Failed init for response, err: %d\n",
- __func__, ret);
- goto out;
- }
- req->report_flow_status_valid = 1;
- req->report_flow_status = reg;
- req->report_tx_link_status_valid = 1;
- req->report_tx_link_status = reg;
- ret = qmi_send_request(dfc_handle, ssctl, &txn,
- QMI_DFC_INDICATION_REGISTER_REQ_V01,
- QMI_DFC_INDICATION_REGISTER_REQ_V01_MAX_MSG_LEN,
- dfc_indication_register_req_msg_v01_ei, req);
- if (ret < 0) {
- qmi_txn_cancel(&txn);
- pr_err("%s() Failed sending request, err: %d\n",
- __func__, ret);
- goto out;
- }
- ret = qmi_txn_wait(&txn, DFC_TIMEOUT_JF);
- if (ret < 0) {
- pr_err("%s() Response waiting failed, err: %d\n",
- __func__, ret);
- } else if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
- pr_err("%s() Request rejected, result: %d, err: %d\n",
- __func__, resp->resp.result, resp->resp.error);
- ret = -resp->resp.result;
- }
- out:
- kfree(resp);
- kfree(req);
- return ret;
- }
- static int
- dfc_get_flow_status_req(struct qmi_handle *dfc_handle,
- struct sockaddr_qrtr *ssctl,
- struct dfc_get_flow_status_resp_msg_v01 *resp)
- {
- struct dfc_get_flow_status_req_msg_v01 *req;
- struct qmi_txn *txn;
- int ret;
- req = kzalloc(sizeof(*req), GFP_ATOMIC);
- if (!req)
- return -ENOMEM;
- txn = kzalloc(sizeof(*txn), GFP_ATOMIC);
- if (!txn) {
- kfree(req);
- return -ENOMEM;
- }
- ret = qmi_txn_init(dfc_handle, txn,
- dfc_get_flow_status_resp_msg_v01_ei, resp);
- if (ret < 0) {
- pr_err("%s() Failed init for response, err: %d\n",
- __func__, ret);
- goto out;
- }
- ret = qmi_send_request(dfc_handle, ssctl, txn,
- QMI_DFC_GET_FLOW_STATUS_REQ_V01,
- QMI_DFC_GET_FLOW_STATUS_REQ_V01_MAX_MSG_LEN,
- dfc_get_flow_status_req_msg_v01_ei, req);
- if (ret < 0) {
- qmi_txn_cancel(txn);
- pr_err("%s() Failed sending request, err: %d\n",
- __func__, ret);
- goto out;
- }
- ret = qmi_txn_wait(txn, DFC_TIMEOUT_JF);
- if (ret < 0) {
- pr_err("%s() Response waiting failed, err: %d\n",
- __func__, ret);
- } else if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
- pr_err("%s() Request rejected, result: %d, err: %d\n",
- __func__, resp->resp.result, resp->resp.error);
- ret = -resp->resp.result;
- }
- out:
- kfree(txn);
- kfree(req);
- return ret;
- }
- static int dfc_init_service(struct dfc_qmi_data *data)
- {
- int rc;
- rc = dfc_bind_client_req(&data->handle, &data->ssctl, &data->svc);
- if (rc < 0)
- return rc;
- return dfc_indication_register_req(&data->handle, &data->ssctl, 1);
- }
- static void
- dfc_send_ack(struct net_device *dev, u8 bearer_id, u16 seq, u8 mux_id, u8 type)
- {
- struct qos_info *qos = rmnet_get_qos_pt(dev);
- struct sk_buff *skb;
- struct dfc_ack_cmd *msg;
- int data_size = sizeof(struct dfc_ack_cmd);
- int header_size = sizeof(struct dfc_qmap_header);
- if (!qos)
- return;
- if (dfc_qmap) {
- dfc_qmap_send_ack(qos, bearer_id, seq, type);
- return;
- }
- skb = alloc_skb(data_size, GFP_ATOMIC);
- if (!skb)
- return;
- msg = (struct dfc_ack_cmd *)skb_put(skb, data_size);
- memset(msg, 0, data_size);
- msg->header.cd_bit = 1;
- msg->header.mux_id = mux_id;
- msg->header.pkt_len = htons(data_size - header_size);
- msg->bearer_id = bearer_id;
- msg->command_name = 4;
- msg->cmd_type = 0;
- msg->dfc_seq = htons(seq);
- msg->type = type;
- msg->ver = 2;
- msg->transaction_id = htonl(qos->tran_num);
- skb->dev = qos->real_dev;
- skb->protocol = htons(ETH_P_MAP);
- trace_dfc_qmap_cmd(mux_id, bearer_id, seq, type, qos->tran_num);
- qos->tran_num++;
- rmnet_map_tx_qmap_cmd(skb);
- }
- int dfc_bearer_flow_ctl(struct net_device *dev,
- struct rmnet_bearer_map *bearer,
- struct qos_info *qos)
- {
- bool enable;
- enable = bearer->grant_size ? true : false;
- qmi_rmnet_flow_control(dev, bearer->mq_idx, enable);
- /* Do not flow disable tcp ack q in tcp bidir */
- if (bearer->ack_mq_idx != INVALID_MQ &&
- (enable || !bearer->tcp_bidir))
- qmi_rmnet_flow_control(dev, bearer->ack_mq_idx, enable);
- if (!enable && bearer->ack_req)
- dfc_send_ack(dev, bearer->bearer_id,
- bearer->seq, qos->mux_id,
- DFC_ACK_TYPE_DISABLE);
- return 0;
- }
- static int dfc_all_bearer_flow_ctl(struct net_device *dev,
- struct qos_info *qos, u8 ack_req, u32 ancillary,
- struct dfc_flow_status_info_type_v01 *fc_info)
- {
- struct rmnet_bearer_map *bearer;
- list_for_each_entry(bearer, &qos->bearer_head, list) {
- bearer->grant_size = fc_info->num_bytes;
- bearer->grant_thresh =
- qmi_rmnet_grant_per(bearer->grant_size);
- bearer->seq = fc_info->seq_num;
- bearer->ack_req = ack_req;
- bearer->tcp_bidir = DFC_IS_TCP_BIDIR(ancillary);
- bearer->last_grant = fc_info->num_bytes;
- bearer->last_seq = fc_info->seq_num;
- dfc_bearer_flow_ctl(dev, bearer, qos);
- }
- return 0;
- }
- static int dfc_update_fc_map(struct net_device *dev, struct qos_info *qos,
- u8 ack_req, u32 ancillary,
- struct dfc_flow_status_info_type_v01 *fc_info)
- {
- struct rmnet_bearer_map *itm = NULL;
- int rc = 0;
- bool action = false;
- itm = qmi_rmnet_get_bearer_map(qos, fc_info->bearer_id);
- if (!itm)
- itm = qmi_rmnet_get_bearer_noref(qos, fc_info->bearer_id);
- if (itm) {
- /* The RAT switch flag indicates the start and end of
- * the switch. Ignore indications in between.
- */
- if (DFC_IS_RAT_SWITCH(ancillary))
- itm->rat_switch = !fc_info->num_bytes;
- else
- if (itm->rat_switch)
- return 0;
- /* If TX is OFF but we received grant, ignore it */
- if (itm->tx_off && fc_info->num_bytes > 0)
- return 0;
- if ((itm->grant_size == 0 && fc_info->num_bytes > 0) ||
- (itm->grant_size > 0 && fc_info->num_bytes == 0))
- action = true;
- /* This is needed by qmap */
- if (dfc_qmap && itm->ack_req && !ack_req && itm->grant_size)
- dfc_qmap_send_ack(qos, itm->bearer_id,
- itm->seq, DFC_ACK_TYPE_DISABLE);
- itm->grant_size = fc_info->num_bytes;
- itm->grant_thresh = qmi_rmnet_grant_per(itm->grant_size);
- itm->seq = fc_info->seq_num;
- itm->ack_req = ack_req;
- itm->tcp_bidir = DFC_IS_TCP_BIDIR(ancillary);
- itm->last_grant = fc_info->num_bytes;
- itm->last_seq = fc_info->seq_num;
- if (action)
- rc = dfc_bearer_flow_ctl(dev, itm, qos);
- }
- return rc;
- }
- void dfc_do_burst_flow_control(struct dfc_qmi_data *dfc,
- struct dfc_flow_status_ind_msg_v01 *ind)
- {
- struct net_device *dev;
- struct qos_info *qos;
- struct dfc_flow_status_info_type_v01 *flow_status;
- struct dfc_ancillary_info_type_v01 *ai;
- u8 ack_req = ind->eod_ack_reqd_valid ? ind->eod_ack_reqd : 0;
- u32 ancillary;
- int i, j;
- rcu_read_lock();
- for (i = 0; i < ind->flow_status_len; i++) {
- flow_status = &ind->flow_status[i];
- ancillary = 0;
- if (ind->ancillary_info_valid) {
- for (j = 0; j < ind->ancillary_info_len; j++) {
- ai = &ind->ancillary_info[j];
- if (ai->mux_id == flow_status->mux_id &&
- ai->bearer_id == flow_status->bearer_id) {
- ancillary = ai->reserved;
- break;
- }
- }
- }
- trace_dfc_flow_ind(dfc->index,
- i, flow_status->mux_id,
- flow_status->bearer_id,
- flow_status->num_bytes,
- flow_status->seq_num,
- ack_req,
- ancillary);
- dev = rmnet_get_rmnet_dev(dfc->rmnet_port,
- flow_status->mux_id);
- if (!dev)
- goto clean_out;
- qos = (struct qos_info *)rmnet_get_qos_pt(dev);
- if (!qos)
- continue;
- spin_lock_bh(&qos->qos_lock);
- if (qmi_rmnet_ignore_grant(dfc->rmnet_port)) {
- spin_unlock_bh(&qos->qos_lock);
- continue;
- }
- if (unlikely(flow_status->bearer_id == 0xFF))
- dfc_all_bearer_flow_ctl(
- dev, qos, ack_req, ancillary, flow_status);
- else
- dfc_update_fc_map(
- dev, qos, ack_req, ancillary, flow_status);
- spin_unlock_bh(&qos->qos_lock);
- }
- clean_out:
- rcu_read_unlock();
- }
- static void dfc_update_tx_link_status(struct net_device *dev,
- struct qos_info *qos, u8 tx_status,
- struct dfc_bearer_info_type_v01 *binfo)
- {
- struct rmnet_bearer_map *itm = NULL;
- itm = qmi_rmnet_get_bearer_map(qos, binfo->bearer_id);
- if (!itm)
- return;
- /* If no change in tx status, ignore */
- if (itm->tx_off == !tx_status)
- return;
- if (itm->grant_size && !tx_status) {
- itm->grant_size = 0;
- itm->tcp_bidir = false;
- dfc_bearer_flow_ctl(dev, itm, qos);
- } else if (itm->grant_size == 0 && tx_status && !itm->rat_switch) {
- itm->grant_size = DEFAULT_GRANT;
- itm->grant_thresh = qmi_rmnet_grant_per(DEFAULT_GRANT);
- itm->seq = 0;
- itm->ack_req = 0;
- dfc_bearer_flow_ctl(dev, itm, qos);
- }
- itm->tx_off = !tx_status;
- }
- void dfc_handle_tx_link_status_ind(struct dfc_qmi_data *dfc,
- struct dfc_tx_link_status_ind_msg_v01 *ind)
- {
- struct net_device *dev;
- struct qos_info *qos;
- struct dfc_bearer_info_type_v01 *bearer_info;
- int i;
- rcu_read_lock();
- for (i = 0; i < ind->bearer_info_len; i++) {
- bearer_info = &ind->bearer_info[i];
- trace_dfc_tx_link_status_ind(dfc->index, i,
- ind->tx_status,
- bearer_info->mux_id,
- bearer_info->bearer_id);
- dev = rmnet_get_rmnet_dev(dfc->rmnet_port,
- bearer_info->mux_id);
- if (!dev)
- goto clean_out;
- qos = (struct qos_info *)rmnet_get_qos_pt(dev);
- if (!qos)
- continue;
- spin_lock_bh(&qos->qos_lock);
- dfc_update_tx_link_status(
- dev, qos, ind->tx_status, bearer_info);
- spin_unlock_bh(&qos->qos_lock);
- }
- clean_out:
- rcu_read_unlock();
- }
- static void dfc_qmi_ind_work(struct work_struct *work)
- {
- struct dfc_qmi_data *dfc = container_of(work, struct dfc_qmi_data,
- qmi_ind_work);
- struct dfc_svc_ind *svc_ind;
- unsigned long flags;
- if (!dfc)
- return;
- local_bh_disable();
- do {
- spin_lock_irqsave(&dfc->qmi_ind_lock, flags);
- svc_ind = list_first_entry_or_null(&dfc->qmi_ind_q,
- struct dfc_svc_ind, list);
- if (svc_ind)
- list_del(&svc_ind->list);
- spin_unlock_irqrestore(&dfc->qmi_ind_lock, flags);
- if (!svc_ind)
- break;
- if (!dfc->restart_state) {
- if (svc_ind->msg_id == QMI_DFC_FLOW_STATUS_IND_V01)
- dfc_do_burst_flow_control(
- dfc, &svc_ind->d.dfc_info);
- else if (svc_ind->msg_id ==
- QMI_DFC_TX_LINK_STATUS_IND_V01)
- dfc_handle_tx_link_status_ind(
- dfc, &svc_ind->d.tx_status);
- }
- kfree(svc_ind);
- } while (1);
- local_bh_enable();
- qmi_rmnet_set_dl_msg_active(dfc->rmnet_port);
- }
- static void dfc_clnt_ind_cb(struct qmi_handle *qmi, struct sockaddr_qrtr *sq,
- struct qmi_txn *txn, const void *data)
- {
- struct dfc_qmi_data *dfc = container_of(qmi, struct dfc_qmi_data,
- handle);
- struct dfc_flow_status_ind_msg_v01 *ind_msg;
- struct dfc_svc_ind *svc_ind;
- unsigned long flags;
- if (qmi != &dfc->handle)
- return;
- ind_msg = (struct dfc_flow_status_ind_msg_v01 *)data;
- if (ind_msg->flow_status_valid) {
- if (ind_msg->flow_status_len > DFC_MAX_BEARERS_V01) {
- pr_err("%s() Invalid fc info len: %d\n",
- __func__, ind_msg->flow_status_len);
- return;
- }
- svc_ind = kzalloc(sizeof(struct dfc_svc_ind), GFP_ATOMIC);
- if (!svc_ind)
- return;
- svc_ind->msg_id = QMI_DFC_FLOW_STATUS_IND_V01;
- memcpy(&svc_ind->d.dfc_info, ind_msg, sizeof(*ind_msg));
- spin_lock_irqsave(&dfc->qmi_ind_lock, flags);
- list_add_tail(&svc_ind->list, &dfc->qmi_ind_q);
- spin_unlock_irqrestore(&dfc->qmi_ind_lock, flags);
- queue_work(dfc->dfc_wq, &dfc->qmi_ind_work);
- }
- }
- static void dfc_tx_link_status_ind_cb(struct qmi_handle *qmi,
- struct sockaddr_qrtr *sq,
- struct qmi_txn *txn, const void *data)
- {
- struct dfc_qmi_data *dfc = container_of(qmi, struct dfc_qmi_data,
- handle);
- struct dfc_tx_link_status_ind_msg_v01 *ind_msg;
- struct dfc_svc_ind *svc_ind;
- unsigned long flags;
- if (qmi != &dfc->handle)
- return;
- ind_msg = (struct dfc_tx_link_status_ind_msg_v01 *)data;
- if (ind_msg->bearer_info_valid) {
- if (ind_msg->bearer_info_len > DFC_MAX_BEARERS_V01) {
- pr_err("%s() Invalid bearer info len: %d\n",
- __func__, ind_msg->bearer_info_len);
- return;
- }
- svc_ind = kzalloc(sizeof(struct dfc_svc_ind), GFP_ATOMIC);
- if (!svc_ind)
- return;
- svc_ind->msg_id = QMI_DFC_TX_LINK_STATUS_IND_V01;
- memcpy(&svc_ind->d.tx_status, ind_msg, sizeof(*ind_msg));
- spin_lock_irqsave(&dfc->qmi_ind_lock, flags);
- list_add_tail(&svc_ind->list, &dfc->qmi_ind_q);
- spin_unlock_irqrestore(&dfc->qmi_ind_lock, flags);
- queue_work(dfc->dfc_wq, &dfc->qmi_ind_work);
- }
- }
- static void dfc_svc_init(struct work_struct *work)
- {
- int rc = 0;
- struct dfc_qmi_data *data = container_of(work, struct dfc_qmi_data,
- svc_arrive);
- struct qmi_info *qmi;
- if (data->restart_state == 1)
- return;
- rc = dfc_init_service(data);
- if (rc < 0) {
- pr_err("%s Failed to init service, err[%d]\n", __func__, rc);
- return;
- }
- if (data->restart_state == 1)
- return;
- while (!rtnl_trylock()) {
- if (!data->restart_state)
- cond_resched();
- else
- return;
- }
- qmi = (struct qmi_info *)rmnet_get_qmi_pt(data->rmnet_port);
- if (!qmi) {
- rtnl_unlock();
- return;
- }
- qmi->dfc_pending[data->index] = NULL;
- qmi->dfc_clients[data->index] = (void *)data;
- trace_dfc_client_state_up(data->index,
- data->svc.instance,
- data->svc.ep_type,
- data->svc.iface_id);
- rtnl_unlock();
- pr_info("Connection established with the DFC Service\n");
- }
- static int dfc_svc_arrive(struct qmi_handle *qmi, struct qmi_service *svc)
- {
- struct dfc_qmi_data *data = container_of(qmi, struct dfc_qmi_data,
- handle);
- data->ssctl.sq_family = AF_QIPCRTR;
- data->ssctl.sq_node = svc->node;
- data->ssctl.sq_port = svc->port;
- queue_work(data->dfc_wq, &data->svc_arrive);
- return 0;
- }
- static void dfc_svc_exit(struct qmi_handle *qmi, struct qmi_service *svc)
- {
- struct dfc_qmi_data *data = container_of(qmi, struct dfc_qmi_data,
- handle);
- if (!data)
- pr_debug("%s() data is null\n", __func__);
- }
- static struct qmi_ops server_ops = {
- .new_server = dfc_svc_arrive,
- .del_server = dfc_svc_exit,
- };
- static struct qmi_msg_handler qmi_indication_handler[] = {
- {
- .type = QMI_INDICATION,
- .msg_id = QMI_DFC_FLOW_STATUS_IND_V01,
- .ei = dfc_flow_status_ind_v01_ei,
- .decoded_size = sizeof(struct dfc_flow_status_ind_msg_v01),
- .fn = dfc_clnt_ind_cb,
- },
- {
- .type = QMI_INDICATION,
- .msg_id = QMI_DFC_TX_LINK_STATUS_IND_V01,
- .ei = dfc_tx_link_status_ind_v01_ei,
- .decoded_size = sizeof(struct dfc_tx_link_status_ind_msg_v01),
- .fn = dfc_tx_link_status_ind_cb,
- },
- {},
- };
- int dfc_qmi_client_init(void *port, int index, struct svc_info *psvc,
- struct qmi_info *qmi)
- {
- struct dfc_qmi_data *data;
- int rc = -ENOMEM;
- if (!port || !qmi)
- return -EINVAL;
- data = kzalloc(sizeof(struct dfc_qmi_data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
- data->rmnet_port = port;
- data->index = index;
- data->restart_state = 0;
- memcpy(&data->svc, psvc, sizeof(data->svc));
- INIT_WORK(&data->qmi_ind_work, dfc_qmi_ind_work);
- INIT_LIST_HEAD(&data->qmi_ind_q);
- spin_lock_init(&data->qmi_ind_lock);
- data->dfc_wq = create_singlethread_workqueue("dfc_wq");
- if (!data->dfc_wq) {
- pr_err("%s Could not create workqueue\n", __func__);
- goto err0;
- }
- INIT_WORK(&data->svc_arrive, dfc_svc_init);
- rc = qmi_handle_init(&data->handle,
- QMI_DFC_GET_FLOW_STATUS_RESP_V01_MAX_MSG_LEN,
- &server_ops, qmi_indication_handler);
- if (rc < 0) {
- pr_err("%s: failed qmi_handle_init - rc[%d]\n", __func__, rc);
- goto err1;
- }
- rc = qmi_add_lookup(&data->handle, DFC_SERVICE_ID_V01,
- DFC_SERVICE_VERS_V01,
- psvc->instance);
- if (rc < 0) {
- pr_err("%s: failed qmi_add_lookup - rc[%d]\n", __func__, rc);
- goto err2;
- }
- qmi->dfc_pending[index] = (void *)data;
- return 0;
- err2:
- qmi_handle_release(&data->handle);
- err1:
- destroy_workqueue(data->dfc_wq);
- err0:
- kfree(data);
- return rc;
- }
- void dfc_qmi_client_exit(void *dfc_data)
- {
- struct dfc_qmi_data *data = (struct dfc_qmi_data *)dfc_data;
- if (!data) {
- pr_err("%s() data is null\n", __func__);
- return;
- }
- data->restart_state = 1;
- trace_dfc_client_state_down(data->index, 0);
- qmi_handle_release(&data->handle);
- drain_workqueue(data->dfc_wq);
- destroy_workqueue(data->dfc_wq);
- kfree(data);
- }
- void dfc_qmi_burst_check(struct net_device *dev, struct qos_info *qos,
- int ip_type, u32 mark, unsigned int len)
- {
- struct rmnet_bearer_map *bearer = NULL;
- struct rmnet_flow_map *itm;
- u32 start_grant;
- spin_lock_bh(&qos->qos_lock);
- if (dfc_mode == DFC_MODE_MQ_NUM) {
- /* Mark is mq num */
- if (likely(mark < MAX_MQ_NUM))
- bearer = qos->mq[mark].bearer;
- } else {
- /* Mark is flow_id */
- itm = qmi_rmnet_get_flow_map(qos, mark, ip_type);
- if (likely(itm))
- bearer = itm->bearer;
- }
- if (unlikely(!bearer))
- goto out;
- trace_dfc_flow_check(dev->name, bearer->bearer_id,
- len, mark, bearer->grant_size);
- if (!bearer->grant_size)
- goto out;
- start_grant = bearer->grant_size;
- if (len >= bearer->grant_size)
- bearer->grant_size = 0;
- else
- bearer->grant_size -= len;
- if (start_grant > bearer->grant_thresh &&
- bearer->grant_size <= bearer->grant_thresh) {
- dfc_send_ack(dev, bearer->bearer_id,
- bearer->seq, qos->mux_id,
- DFC_ACK_TYPE_THRESHOLD);
- }
- if (!bearer->grant_size)
- dfc_bearer_flow_ctl(dev, bearer, qos);
- out:
- spin_unlock_bh(&qos->qos_lock);
- }
- void dfc_qmi_query_flow(void *dfc_data)
- {
- struct dfc_qmi_data *data = (struct dfc_qmi_data *)dfc_data;
- struct dfc_get_flow_status_resp_msg_v01 *resp;
- struct dfc_svc_ind *svc_ind;
- int rc;
- resp = kzalloc(sizeof(*resp), GFP_ATOMIC);
- if (!resp)
- return;
- svc_ind = kzalloc(sizeof(*svc_ind), GFP_ATOMIC);
- if (!svc_ind) {
- kfree(resp);
- return;
- }
- if (!data)
- goto done;
- rc = dfc_get_flow_status_req(&data->handle, &data->ssctl, resp);
- if (rc < 0 || !resp->flow_status_valid || resp->flow_status_len < 1 ||
- resp->flow_status_len > DFC_MAX_BEARERS_V01)
- goto done;
- svc_ind->d.dfc_info.flow_status_valid = resp->flow_status_valid;
- svc_ind->d.dfc_info.flow_status_len = resp->flow_status_len;
- memcpy(&svc_ind->d.dfc_info.flow_status, resp->flow_status,
- sizeof(resp->flow_status[0]) * resp->flow_status_len);
- dfc_do_burst_flow_control(data, &svc_ind->d.dfc_info);
- done:
- kfree(svc_ind);
- kfree(resp);
- }
|