From patchwork Fri Mar 1 23:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13579285 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ADD05EE76 for ; Fri, 1 Mar 2024 23:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; cv=none; b=BiGWU+WAZzxNTyV+3T+fQn067yKyef4vU6rQRPsyLEQahKlMYT3mz1/XL6PEPJdUExg01pHnPG69uGysNNDcCndsmXrzzZHIsYNvCkAdqfpO5ulzbPG8+fcXjCCiosyTeLjTpWYP8Zi7ELkCPFDVeacKOo31LkZ7pcBFz3zt/J8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; c=relaxed/simple; bh=/evW93q/I4eEioOXydPbCyDa/nNlwvam9yqsOfrVGRE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=c8A2jUQaSvztJOdozp9QSx5silrrs7sMnThcDli66024GKVYbsQiW7zDBm+EYHKUS5HStXBrPwOtEfmqXZI707FG2rQTwXUuzOwHB1ZtH1W7GV8uGAuT4yJFQ5PyUMAYfX5E08VwSiOqrzLH9hOySj6ra2U59Zbd9cW5VtbY9x8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=Q6v/8bT9; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=rpy6j2TS; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="Q6v/8bT9"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="rpy6j2TS" Received: from pps.filterd (m0286619.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 421EU2Av029480 for ; Fri, 1 Mar 2024 15:45:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:mime-version:content-type; s=ppemail; bh=lx3PKlAeXHCwAUfyO/YzDk/6VoMZEcxAhny/2Rz9PGI=; b=Q 6v/8bT9J9/dAy6CpOy3TOIV3N5T6TIrCF7P5ieHHQrA0JJKGJCvCYZqE2gzJaw9a WEJpmqbB7dfqUTywJ0sCEG0bvCFDuwOuHMqO4JuZjByFfI82UT4Sn/lvsDg+AE/4 E32h+cvqTOyeaJHZ6CJOgQSTSckpGyPnxk841H7Y8HzIUScWHeAZCG7yzW02x3Ze ivlWMRAD+mve+aM3B+2vjkIzDKS2FsKOPQJAGBO2FBeXxeQ5ZO+gEK5YhC+eWcXk 9FmpZjA0vQq/xYHkwxtyX1KhMq+YxEBuInIuyp4O0nf60sXlUVQIFvjYl55bpydK L/HUWhpmV5zP/nFpcuAgA== Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wj6jcjmpm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 01 Mar 2024 15:45:51 -0800 (PST) Received: by mail-il1-f199.google.com with SMTP id e9e14a558f8ab-36516d55c5fso33374865ab.2 for ; Fri, 01 Mar 2024 15:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1709336750; x=1709941550; darn=lists.linux.dev; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=lx3PKlAeXHCwAUfyO/YzDk/6VoMZEcxAhny/2Rz9PGI=; b=rpy6j2TSOLEmnERq1Feo53lZZTvCkhq3c98QmoViGkmHO+H0CUe7ni9uHTAtFnGjk5 JGye3z45/tOt339ISY/ZXW2yo6wPEDMlb/v6fMVM6faKj9cA1RUcSV1DiGoHmcC+edma fHf0SoJsS9x75SzCXn0EnFrzPJV97IAUWkexzkMNNGe6ruxJD03RSc7kfowRe8ibKuBS 05iEWEOGpiIDv4VmfksLYId73paUgpXYTiisGuhCovacqI3gvVKz54i78GNgx60/Kamj /JnxJ+kmZlzj3WlFotPqctUkqimqU6NbKXdQ8cQZjyNPrwvi1/xYv2n1GbQtJtFluj7m aIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709336750; x=1709941550; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=lx3PKlAeXHCwAUfyO/YzDk/6VoMZEcxAhny/2Rz9PGI=; b=Y3zaZXoZqUbCWlG5cV+z6fUiurimNkSw++peuxGFinJr3fLEoQkWeDmvOF6vN7X6pF mBlQnxI5FavLaIGPCmkCO2viot5xiL5mic/Vav2t8HJcdPOi7H2DAG4Dl17RQnsJHfXR jx9vZLsdQR+v5eYO7TSv4Gzd0cwIz8R4PrYUsuUKgQ77ajK3mtqlCsztyceoYlQ81a7n jpohsHFQ6wduRiF1BrR+4L2KkOR+MNrCyM+kjFJ8JtTXWh/CHo+4JZN8g96Ja18A92+J g9w3ihg0tASBq9+KxHebjk9wu6rED6Cxt9zEzkbXhnkheyXkW0g0J27hWn6Pi/RsRTH/ m0QQ== X-Gm-Message-State: AOJu0YzIMnf1D9fnMaaVdcpTrg0BhaDvGoQ4YJksJkC4G4bxumBTAeja 7ANO7I5QuCuilHabBO2mm3/OOiLxGlBM144oPWJ1aj+gxP3mnk6VWx0QpzjR189UT/lUq3N+bCX OdYyDve3vZdYhbO/BZfxniKFOJAJHshlK1ya5FOPiYWog+C1vwSMiKABdrxYDEq1j+N3Vev/DaK o7V3U9poiqD5hvbpstIhE3vo4+FjVCLq+oYIoPxYfkuQ01jY8= X-Received: by 2002:a05:6e02:218c:b0:365:1749:cae5 with SMTP id j12-20020a056e02218c00b003651749cae5mr3232741ila.19.1709336750627; Fri, 01 Mar 2024 15:45:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4z1XCFtOxkD7Q3+Z+ZFU+vYJU+zAH3eDg12B48cxCbfm1U4kDLLf0ZhExkFY8gIgSMgA6ig== X-Received: by 2002:a05:6e02:218c:b0:365:1749:cae5 with SMTP id j12-20020a056e02218c00b003651749cae5mr3232733ila.19.1709336750355; Fri, 01 Mar 2024 15:45:50 -0800 (PST) Received: from cs-1zgl0npt-heavy-homedir-303475.corp.robot.car (122.32.128.34.bc.googleusercontent.com. [34.128.32.122]) by smtp.gmail.com with ESMTPSA id c6-20020a92cf06000000b00365bd7f608esm1137012ilo.40.2024.03.01.15.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:45:50 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v4 1/4] qmi: Add an abstract group id to services and requests Date: Fri, 1 Mar 2024 17:45:32 -0600 Message-ID: <20240301234539.1581017-1-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.43.2 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: IxSzpF_KF2-ZLN45ZihmdT2NZqVBo9c9 X-Proofpoint-ORIG-GUID: IxSzpF_KF2-ZLN45ZihmdT2NZqVBo9c9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-01_22,2024-03-01_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 clxscore=1015 mlxscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403010195 This will allow services and requests to be matched without using the QMUX client id which does not exist in QRTR. --- drivers/qmimodem/qmi.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 23a5fee7..44d1738d 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -61,6 +61,7 @@ struct qmi_service_info { struct qmi_request { uint16_t tid; + unsigned int group_id; /* Always 0 for control */ uint8_t client; qmi_message_func_t callback; void *user_data; @@ -90,6 +91,7 @@ struct qmi_device { struct l_queue *req_queue; struct l_queue *service_queue; struct l_queue *discovery_queue; + unsigned int next_group_id; /* Matches requests with services */ uint16_t next_service_tid; qmi_debug_func_t debug_func; void *debug_data; @@ -119,6 +121,7 @@ struct qmi_service { int ref_count; struct qmi_device *device; struct qmi_service_info info; + unsigned int group_id; uint8_t client_id; uint16_t next_notify_id; struct l_queue *notify_list; @@ -692,8 +695,9 @@ static void wakeup_writer(struct qmi_device *device) device->writer_active = true; } -static uint16_t __request_submit(struct qmi_device *device, - struct qmi_request *req) +static uint16_t __service_request_submit(struct qmi_device *device, + struct qmi_service *service, + struct qmi_request *req) { struct qmi_service_hdr *hdr = (struct qmi_service_hdr *) &req->data[QMI_MUX_HDR_SIZE]; @@ -703,6 +707,8 @@ static uint16_t __request_submit(struct qmi_device *device, if (device->next_service_tid < 256) device->next_service_tid = 256; + req->group_id = service->group_id; + hdr->type = 0x00; hdr->transaction = L_CPU_TO_LE16(req->tid); @@ -1397,6 +1403,11 @@ static struct qmi_service *service_create(struct qmi_device *device, service->client_id = client_id; service->notify_list = l_queue_new(); + if (device->next_group_id == 0) /* 0 is reserved for control */ + device->next_group_id = 1; + + service->group_id = device->next_group_id++; + memcpy(&service->info, info, sizeof(service->info)); __debug_device(device, "service created [client=%d,type=%d]", @@ -2667,7 +2678,7 @@ uint16_t qmi_service_send(struct qmi_service *service, if (!service) return 0; - if (!service->client_id) + if (!service->group_id) return 0; device = service->device; @@ -2680,15 +2691,15 @@ uint16_t qmi_service_send(struct qmi_service *service, data->user_data = user_data; data->destroy = destroy; - req = __request_alloc(service->info.service_type, service->client_id, - message, + req = __request_alloc(service->info.service_type, + service->client_id, message, param ? param->data : NULL, param ? param->length : 0, service_send_callback, data); qmi_param_free(param); - tid = __request_submit(device, req); + tid = __service_request_submit(device, service, req); return tid; } @@ -2729,9 +2740,9 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) static bool remove_req_if_match(void *data, void *user_data) { struct qmi_request *req = data; - uint8_t client = L_PTR_TO_UINT(user_data); + unsigned int group_id = L_PTR_TO_UINT(user_data); - if (!req->client || req->client != client) + if (req->group_id != group_id) return false; service_send_free(req->user_data); @@ -2740,10 +2751,10 @@ static bool remove_req_if_match(void *data, void *user_data) return true; } -static void remove_client(struct l_queue *queue, uint8_t client) +static void remove_client(struct l_queue *queue, unsigned int group_id) { l_queue_foreach_remove(queue, remove_req_if_match, - L_UINT_TO_PTR(client)); + L_UINT_TO_PTR(group_id)); } bool qmi_service_cancel_all(struct qmi_service *service) @@ -2753,15 +2764,15 @@ bool qmi_service_cancel_all(struct qmi_service *service) if (!service) return false; - if (!service->client_id) + if (!service->group_id) return false; device = service->device; if (!device) return false; - remove_client(device->req_queue, service->client_id); - remove_client(device->service_queue, service->client_id); + remove_client(device->req_queue, service->group_id); + remove_client(device->service_queue, service->group_id); return true; } From patchwork Fri Mar 1 23:45:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13579284 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C75A45EE64 for ; Fri, 1 Mar 2024 23:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336755; cv=none; b=hU8afWH+FrKbxqhN3fWgfq37Y+nZqMRIo1uQyiro9TJv+lhLVWsyyOf/ItPpTRbVWOfdX2a61TYYFI6oCV892CO/G5AMi2XHMBwz4TM7o4FVKzX8dx0YgtTAKgKBvy6oB6RPHZC+mfvcWizk8ZNq/LpIaGxX5XKc/KLmi4hT068= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336755; c=relaxed/simple; bh=KdyoEURJLvexlSecaodikI+afQxJ+Eka8oMRBUnQ/FY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kU7SawDYSkNfCpzeR+LV5Vep4R3+iC+oG/kd6kQyBXg9lYevw/9Dtd+sWUB9YPaWxkTPEkxSoVjVYTRpdRB3IS2zb20tSWykD7OBjFQOTFzfi1FRbdQfeLALoPbEc4BYQtrtuq0z0Ces8dbCMcjGMXpOD0N5hzABn4EIqxruGe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=icQxkPD8; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=lVs2hSIZ; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="icQxkPD8"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="lVs2hSIZ" Received: from pps.filterd (m0286618.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 421FWGn3009998 for ; Fri, 1 Mar 2024 15:45:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=LfvOTbDRdyK6APQJzsz5j5 UXNAaBgl7MAYAH3u946J4=; b=icQxkPD81UlfURnp//AUVUScf4YcbhnFsBFy8a JryYxNskL5hVQzafUomlS7dVh7DbRG9sXLgV25ecynMUm4YD0TZvYJ/e6jXcmqkX zc9PKb16mXwhxXZHq7OySCVaspLuaTO8xf2lu4SvB/lND8BKCmyFfbYLjhRkEzXj 9aLfM+R81sZ4Hxm7WyQtpyShPQc7qtwbSq83m8KemdjVZw/72nWpwWiT5E7Tbjqs 84pjoFJRScbaYBCporbHCtJoy4nk5HcLR0LDLGKY094NHptBTKcBdkSiaQQSTBT5 Btf0g/0yydjj8s5Hoo+G2kD1cGwObSqs4JBT4GGq5qiJDsFA== Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wjxassed1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 01 Mar 2024 15:45:52 -0800 (PST) Received: by mail-io1-f69.google.com with SMTP id ca18e2360f4ac-7c7ee7fa1caso298555039f.0 for ; Fri, 01 Mar 2024 15:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1709336751; x=1709941551; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=LfvOTbDRdyK6APQJzsz5j5UXNAaBgl7MAYAH3u946J4=; b=lVs2hSIZMDYq/SyS05Gg9/tMNyBVOkCwnQ2we1brcKE45Weu7F15+IhWwg2Cf4efjG 4ZH44g0TOL/NQOgHzgobPLoV3ym6d1HtWGEgxaj4tdvGRisOio/n+cDWuH7HKZjDCE4E ggqS6TqmcUugBf+n9J38yYgB/Qh/It8BP3G7jlOo1wRcGmNTqBPBVjRAumxkVORoR4sl R1IIFrnQxq8ypNWenC2uwiHF82se++MTDPc4QC2sqigSwhgJcIQieGHWUFscep4s1x91 F/qVgJgo419Xq8EfK7JxlXCTOcI+UA6db4xMuZhusFQR/LdpfyxctHl1jUkdtlWhi+8b EUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709336751; x=1709941551; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LfvOTbDRdyK6APQJzsz5j5UXNAaBgl7MAYAH3u946J4=; b=HkSd+p9NIePW2Oj+IUbf6z1DstnxqDhjKzLweY1a3gJtff4LWcRpDijgMK3aXgh64S ucR8baZRJmhCHlO9IJsJS2DjvR9HsqLkP96h99vKnd45RIiWBZMuU8xLDVmN06wmoxCF qUzflO7Pcnymln0fbB+8T0y3xObKCYoyv3ffKtKR75sx+QwmYXuDgOkWXT8iBjYH/hLn 2LM5Vo+RJe8kV57yQ+2CCOV9EUt4+ZXPVK4cku4nUbhRK7u7h89TlHk4dpP9uBVgpgVO PTbiigoBKkP3TsrEhs9jq9lLXlHeKdgaMuAgtQWVAAjWMu41ICE/nwlPJe0PdhIo4Hsr Dtew== X-Gm-Message-State: AOJu0YyTPtyQ7D7GSpa3/B9yz6CAIBZ34ehCEBd8vhavES54PLkPLTYO bYSbJDXRTs594kaiOWo7CwkvXZwQ8DrCDHBiJU8MVH+DxG1LQ0G9peHR8T1VXfqwPF8fmp/sXxK iAZl0mBx868TXkiJ3ySeNYxRA+rHVf37kNBaAgCrX1yKW9bYFjuGAbM5/H4APgOr26qNXZGElUL hUm+5W6o1ArEswDMUD1dq1WB58aIh7bhJVJchF3gc8R3NgbV0= X-Received: by 2002:a05:6e02:20c7:b0:363:c4b9:d931 with SMTP id 7-20020a056e0220c700b00363c4b9d931mr3764509ilq.20.1709336751012; Fri, 01 Mar 2024 15:45:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1VIBO0PH7aoYuQI6emgCQ2PjAa0xRRRNqHtrOAhsFrZzNtvqj9aTGEm+kizRBaEMxvJEdIw== X-Received: by 2002:a05:6e02:20c7:b0:363:c4b9:d931 with SMTP id 7-20020a056e0220c700b00363c4b9d931mr3764498ilq.20.1709336750692; Fri, 01 Mar 2024 15:45:50 -0800 (PST) Received: from cs-1zgl0npt-heavy-homedir-303475.corp.robot.car (122.32.128.34.bc.googleusercontent.com. [34.128.32.122]) by smtp.gmail.com with ESMTPSA id c6-20020a92cf06000000b00365bd7f608esm1137012ilo.40.2024.03.01.15.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:45:50 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v4 2/4] qmi: Store the service info in the request Date: Fri, 1 Mar 2024 17:45:33 -0600 Message-ID: <20240301234539.1581017-2-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301234539.1581017-1-steve.schrock@getcruise.com> References: <20240301234539.1581017-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: zQcpo7lpq38UQF-PzAbsfaEurXTYD-6k X-Proofpoint-GUID: zQcpo7lpq38UQF-PzAbsfaEurXTYD-6k X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-01_22,2024-03-01_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 bulkscore=0 mlxscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403010195 QRTR will need this to write to the appropriate node and port. While here create helper functions to simplify request allocation. --- drivers/qmimodem/qmi.c | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 44d1738d..a2a715e9 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -63,6 +63,7 @@ struct qmi_request { uint16_t tid; unsigned int group_id; /* Always 0 for control */ uint8_t client; + struct qmi_service_info info; /* Not used for control requests */ qmi_message_func_t callback; void *user_data; uint16_t len; @@ -260,6 +261,30 @@ static struct qmi_request *__request_alloc(uint8_t service, return req; } +static struct qmi_request *__control_request_alloc(uint16_t message, + const void *data, uint16_t length, + qmi_message_func_t func, void *user_data) +{ + return __request_alloc(QMI_SERVICE_CONTROL, 0x00, message, + data, length, func, user_data); + +} + +static struct qmi_request *__service_request_alloc( + struct qmi_service_info *info, + uint8_t client, uint16_t message, + const void *data, uint16_t length, + qmi_message_func_t func, void *user_data) +{ + struct qmi_request *req; + + req = __request_alloc(info->service_type, client, message, + data, length, func, user_data); + memcpy(&req->info, info, sizeof(req->info)); + + return req; +} + static void __request_free(void *data) { struct qmi_request *req = data; @@ -1495,9 +1520,8 @@ static bool qmi_device_qmux_sync(struct qmi_device_qmux *qmux, __debug_device(&qmux->super, "Sending sync to reset QMI"); - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_SYNC, NULL, 0, - qmux_sync_callback, data); + req = __control_request_alloc(QMI_CTL_SYNC, NULL, 0, + qmux_sync_callback, data); __ctl_request_submit(qmux, req); @@ -1623,9 +1647,8 @@ static int qmi_device_qmux_discover(struct qmi_device *device, data->user_data = user_data; data->destroy = destroy; - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_GET_VERSION_INFO, - NULL, 0, qmux_discover_callback, data); + req = __control_request_alloc(QMI_CTL_GET_VERSION_INFO, NULL, 0, + qmux_discover_callback, data); data->tid = __ctl_request_submit(qmux, req); data->timeout = l_timeout_create(5, qmux_discover_reply_timeout, @@ -1769,10 +1792,9 @@ static int qmi_device_qmux_client_create(struct qmi_device *device, qmi_device_get_service_version(device, data->type, &data->major, &data->minor); - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_GET_CLIENT_ID, - client_req, sizeof(client_req), - qmux_client_create_callback, data); + req = __control_request_alloc(QMI_CTL_GET_CLIENT_ID, + client_req, sizeof(client_req), + qmux_client_create_callback, data); data->tid = __ctl_request_submit(qmux, req); data->timeout = l_timeout_create(8, qmux_client_create_reply, @@ -1806,10 +1828,9 @@ static void qmi_device_qmux_client_release(struct qmi_device *device, qmux->release_users++; - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_RELEASE_CLIENT_ID, - release_req, sizeof(release_req), - qmux_client_release_callback, qmux); + req = __control_request_alloc(QMI_CTL_RELEASE_CLIENT_ID, + release_req, sizeof(release_req), + qmux_client_release_callback, qmux); __ctl_request_submit(qmux, req); } @@ -2691,11 +2712,11 @@ uint16_t qmi_service_send(struct qmi_service *service, data->user_data = user_data; data->destroy = destroy; - req = __request_alloc(service->info.service_type, - service->client_id, message, - param ? param->data : NULL, - param ? param->length : 0, - service_send_callback, data); + req = __service_request_alloc(&service->info, + service->client_id, message, + param ? param->data : NULL, + param ? param->length : 0, + service_send_callback, data); qmi_param_free(param); From patchwork Fri Mar 1 23:45:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13579286 Received: from mx0a-003ede02.pphosted.com (mx0a-003ede02.pphosted.com [205.220.169.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D5215EE79 for ; Fri, 1 Mar 2024 23:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.169.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; cv=none; b=svVHwolgi114KpamG3pcE7qPuMS5K2zDg9uEPsbF65KIfgeojZWIs7pQM6nFCL5O1uJ3hXXSQRPjo+oJXiqj2+YJasb0fqkDvEvN9gdn9VKxp7LUKcZglbqklpEe1KFe+Gb0AWHnV+HGjHAG/PSdi6jcnwsP5RNIKrGtaJlAEP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; c=relaxed/simple; bh=g7xlCgjqnaEMd7JhRVndY4regekVz7tGNWIR+aGqL/s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=shvNhP04WcKyugKKTaXJyOM84K607V2GW8e3C8eD8K/STWQmLR5IVfcj6iCTRnUMqaXHTOUfY49dSaMBG3yN1naQK23huQHyAxZw5UgSiP5Boe/XpkFK+PXuc2lyIik6x69LYX6YZ+Sxd/VYq2R2e7jChG7pEMWnhjD9U42VYNc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=a6/ftjtY; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=UaIjK8LZ; arc=none smtp.client-ip=205.220.169.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="a6/ftjtY"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="UaIjK8LZ" Received: from pps.filterd (m0286615.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 421DpPqg031343 for ; Fri, 1 Mar 2024 15:45:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=IXJUebPoBUF5FYeLfz81ZW ORpZ3xJwzCgXZ2xI1fBx8=; b=a6/ftjtYZDwrsw7Z0uieqOlgqUCRP72PPDFI9p QW63is76by6R+bvxqSBaI2NVBvP+lcheVnLheL87g7Djrzdn/sUVJQRsMKioGnlb BhGzfRD0TCu3I/mgo0bTVCImgxv1Fjt7OJjBpf1Chk2cSvSy1JQCVoD1ZUZ71PUi 0DVJbrTj2IISEFwToyA0WHsVnn9pvhUuxARyLwZCxJX3pROLa7SiXzlj2t5Ki4de WH13JG91zuigHNh79EJUdmPNFWgfWgGgwwCAu0VEdAPaeaDR7KuzedFlAkHsKQl9 PTzOAAUgsDdxJrEtFu0IV7+AtILogxU4rZCmSM/mYaMl08sw== Received: from mail-il1-f200.google.com (mail-il1-f200.google.com [209.85.166.200]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wjbv9a9uf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 01 Mar 2024 15:45:53 -0800 (PST) Received: by mail-il1-f200.google.com with SMTP id e9e14a558f8ab-3652d6907a1so35912335ab.3 for ; Fri, 01 Mar 2024 15:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1709336752; x=1709941552; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=IXJUebPoBUF5FYeLfz81ZWORpZ3xJwzCgXZ2xI1fBx8=; b=UaIjK8LZEVehigq5Bn9i787wH9mN/bsB1NSuojPRd6J0H5OouiF+E8s/S4355vX2VS l4dIida3ft4hfKP60qMkN41Qxlr1QQ5yiaFQeiqo5FtNI4J+qrhuHJmacMkbRH+Wydtz Q/MJnPyCDHx72k/VHns3JY+FmSPkurXR5minBr9OzLkTyfw+HWtYXSaq9d+RaHCYO0oT zGK5fIjf/J+150BcDUtRDOROJBr+U73EO4mCu+nChm83CUTxMcD1puEQpojlyBJ1P+By sPbwvfWkVIYmbOooJStm+BegIImaul2CiE8ge+WIfKY0s0PXmAd6EPVec83FB5GfXFan gVCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709336752; x=1709941552; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IXJUebPoBUF5FYeLfz81ZWORpZ3xJwzCgXZ2xI1fBx8=; b=FCsQ0mixrvy8b+LmCYwn3B/Fr5A9H6L8vQgj3G9JGS8T9N8cc+BY66/DbtOVNeCfLY BtJaaZQFJ46p9KWbT0WtksHv1NTip9YHYbpOegyHWWk4PpN3nxQEWH7+4HY35XejPSmE 5Y1ThGDWZ2nITSGvyCFwl2UogR1NjQJIG5aMgIWTG8B3a0965I3Kew9HBL26fK+9eGm1 imvQnXclNwEbGJG0TobD8X4JOMKX/M9lognUSGOXn+OThx7mGW8o1qJNxrNx7cLJjfHx BgMUHWbAl1XxNdwgeVxckovrJ4lqtM/9PCyO958pRbq89WruobiN8/gRNcCijrxff/m5 1LKA== X-Gm-Message-State: AOJu0Yys9vgYGOHOeUGyN4VRFrX5cE/nsnGLsY9o/Cs/RkMaYhA19XiP G5Fo0oglr0VSk6hPTasss2TfrZn12n7dk6WSLmPPEmeXJXkVfkH8mrMPh8g+AqxYHIMkCqNYntp XFb0dvSNlXIxs7hkgQ0vprmEYTtEls8C9gjaInmyMQIO07nLa9G2GvnWqXEJUr22uV3HrStdIoe 0PSGlvJXtOCV1Ykr6lONQF1ZgEMe+dw/9jwU9YHQFs9M8ISwo= X-Received: by 2002:a05:6e02:152b:b0:365:4004:83bc with SMTP id i11-20020a056e02152b00b00365400483bcmr3390627ilu.14.1709336752166; Fri, 01 Mar 2024 15:45:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJ06KxRk3dd/M1wXNBOF8dr+0iUWZ2RQXBszXWF5MWGmzIQew0F4RftmXw3IYj/0ijx4IRhA== X-Received: by 2002:a05:6e02:152b:b0:365:4004:83bc with SMTP id i11-20020a056e02152b00b00365400483bcmr3390615ilu.14.1709336751834; Fri, 01 Mar 2024 15:45:51 -0800 (PST) Received: from cs-1zgl0npt-heavy-homedir-303475.corp.robot.car (122.32.128.34.bc.googleusercontent.com. [34.128.32.122]) by smtp.gmail.com with ESMTPSA id c6-20020a92cf06000000b00365bd7f608esm1137012ilo.40.2024.03.01.15.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:45:50 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v4 3/4] qmi: Clean up the __debug_msg function Date: Fri, 1 Mar 2024 17:45:34 -0600 Message-ID: <20240301234539.1581017-3-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301234539.1581017-1-steve.schrock@getcruise.com> References: <20240301234539.1581017-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: lmfhRQHNv6WRtiyicLHzTKVX65hWNwNe X-Proofpoint-ORIG-GUID: lmfhRQHNv6WRtiyicLHzTKVX65hWNwNe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-01_22,2024-03-01_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403010194 There was a lot of redundancy in the function and it was also not ready to handle QRTR messages that do not have a QMUX header. --- drivers/qmimodem/qmi.c | 140 +++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 75 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index a2a715e9..570d9bfd 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -527,94 +527,49 @@ int qmi_error_to_ofono_cme(int qmi_error) } } -static void __debug_msg(const char dir, const void *buf, size_t len, - qmi_debug_func_t function, void *user_data) +static void __debug_msg(char dir, const struct qmi_message_hdr *msg, + uint32_t service_type, uint8_t transaction_type, + uint16_t tid, uint8_t client, uint16_t overall_length, + qmi_debug_func_t function, void *user_data) { - const struct qmi_mux_hdr *hdr; - const struct qmi_message_hdr *msg; const char *service; - const void *ptr; + const void *ptr = msg + 1; uint16_t offset; char strbuf[72 + 16], *str; bool pending_print = false; + const char *transaction_type_string; - if (!function || !len) + if (!function) return; - hdr = buf; - str = strbuf; - service = __service_type_to_string(hdr->service); + service = __service_type_to_string(service_type); if (service) str += sprintf(str, "%c %s", dir, service); else - str += sprintf(str, "%c %d", dir, hdr->service); - - if (hdr->service == QMI_SERVICE_CONTROL) { - const struct qmi_control_hdr *ctl; - const char *type; - - ctl = buf + QMI_MUX_HDR_SIZE; - msg = buf + QMI_MUX_HDR_SIZE + QMI_CONTROL_HDR_SIZE; - ptr = buf + QMI_MUX_HDR_SIZE + QMI_CONTROL_HDR_SIZE + - QMI_MESSAGE_HDR_SIZE; - - switch (ctl->type) { - case 0x00: - type = "_req"; - break; - case 0x01: - type = "_resp"; - break; - case 0x02: - type = "_ind"; - break; - default: - type = ""; - break; - } - - str += sprintf(str, "%s msg=%d len=%d", type, - L_LE16_TO_CPU(msg->message), - L_LE16_TO_CPU(msg->length)); - - str += sprintf(str, " [client=%d,type=%d,tid=%d,len=%d]", - hdr->client, ctl->type, - ctl->transaction, - L_LE16_TO_CPU(hdr->length)); - } else { - const struct qmi_service_hdr *srv; - const char *type; - - srv = buf + QMI_MUX_HDR_SIZE; - msg = buf + QMI_MUX_HDR_SIZE + QMI_SERVICE_HDR_SIZE; - ptr = buf + QMI_MUX_HDR_SIZE + QMI_SERVICE_HDR_SIZE + - QMI_MESSAGE_HDR_SIZE; + str += sprintf(str, "%c %d", dir, service_type); - switch (srv->type) { - case 0x00: - type = "_req"; - break; - case 0x02: - type = "_resp"; - break; - case 0x04: - type = "_ind"; - break; - default: - type = ""; - break; - } + switch (transaction_type) { + case 0x00: + transaction_type_string = "_req"; + break; + case 0x01: + transaction_type_string = "_resp"; + break; + case 0x02: + transaction_type_string = "_ind"; + break; + default: + transaction_type_string = ""; + break; + } - str += sprintf(str, "%s msg=%d len=%d", type, - L_LE16_TO_CPU(msg->message), - L_LE16_TO_CPU(msg->length)); + str += sprintf(str, "%s msg=%d len=%d", transaction_type_string, + L_LE16_TO_CPU(msg->message), + L_LE16_TO_CPU(msg->length)); - str += sprintf(str, " [client=%d,type=%d,tid=%d,len=%d]", - hdr->client, srv->type, - L_LE16_TO_CPU(srv->transaction), - L_LE16_TO_CPU(hdr->length)); - } + str += sprintf(str, " [client=%d,type=%d,tid=%d,len=%d]", + client, transaction_type, tid, overall_length); function(strbuf, user_data); @@ -664,6 +619,41 @@ static void __debug_msg(const char dir, const void *buf, size_t len, function(strbuf, user_data); } +static void __qmux_debug_msg(const char dir, const void *buf, size_t len, + qmi_debug_func_t function, void *user_data) +{ + const struct qmi_mux_hdr *hdr; + const struct qmi_message_hdr *msg; + uint8_t transaction_type; + uint16_t tid; + + if (!len) + return; + + hdr = buf; + + if (hdr->service == QMI_SERVICE_CONTROL) { + const struct qmi_control_hdr *ctl; + + ctl = buf + QMI_MUX_HDR_SIZE; + msg = buf + QMI_MUX_HDR_SIZE + QMI_CONTROL_HDR_SIZE; + + transaction_type = ctl->type; + tid = ctl->transaction; + } else { + const struct qmi_service_hdr *srv; + + srv = buf + QMI_MUX_HDR_SIZE; + msg = buf + QMI_MUX_HDR_SIZE + QMI_SERVICE_HDR_SIZE; + + transaction_type = srv->type; + tid = L_LE16_TO_CPU(srv->transaction); + } + + __debug_msg(dir, msg, hdr->service, transaction_type, tid, hdr->client, + L_LE16_TO_CPU(hdr->length), function, user_data); +} + static void __debug_device(struct qmi_device *device, const char *format, ...) { @@ -1284,7 +1274,7 @@ static int qmi_device_qmux_write(struct qmi_device *device, l_util_hexdump(false, req->data, bytes_written, device->debug_func, device->debug_data); - __debug_msg(' ', req->data, bytes_written, + __qmux_debug_msg(' ', req->data, bytes_written, device->debug_func, device->debug_data); hdr = (struct qmi_mux_hdr *) req->data; @@ -1371,7 +1361,7 @@ static bool received_qmux_data(struct l_io *io, void *user_data) if (bytes_read - offset < len) break; - __debug_msg(' ', buf + offset, len, + __qmux_debug_msg(' ', buf + offset, len, qmux->super.debug_func, qmux->super.debug_data); msg = buf + offset + QMI_MUX_HDR_SIZE; From patchwork Fri Mar 1 23:45:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13579287 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31DD85EE97 for ; Fri, 1 Mar 2024 23:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; cv=none; b=pKoTcNDnnlOIGt+hsvXitJ1mgK9/H55h3At0uKIc32Esy7vvawnk9ES76+itUax2auqU4s+dGmS5UadJABQhz2/JSlIfsDXMjdB3rtj1rIApbXGKdsga4TG6lqYocNr2HG7benWaYsCQ1NRxzrXdc4T6cDQiP7XDMUBmXp+2T6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709336756; c=relaxed/simple; bh=X5OzeFbsTfR/9819WoCQQnDWzxuEc1dMZVsWuXU17JI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pVscCvsrYZTopB62mbTev3O0I6W7g8LzxGtdX3lo6ckXh/y+xhopvDXzwLBFMu5zNHXuAo9FNVuRFP+iqQ3KtHFA6UzCntUrchLjgt2jT/cLwyjQU07dFkDgE191fkRm1OSuVJeyBtubjilUiKH6u3v+rxS+9BMSztDPmnPL0ls= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=eF9lU37S; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=DQ6LZpgv; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="eF9lU37S"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="DQ6LZpgv" Received: from pps.filterd (m0286618.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 421DpRHd007652 for ; Fri, 1 Mar 2024 15:45:54 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=XzvPtRKbKVvFa1jZ10TJNK D8tfofb346+bik9j68JvU=; b=eF9lU37SqrLP2C064mK3AF+5zJknBoDG46JLK9 wkXkyQpQyMRU7aB2yygaG87fpkrmDYBjzWmoxmT6H9SyyYyIfcRtZZZ/tzNyObdc Jphqq6PHj2CyWTl2wUtEEAcUvwiEw8WePfCaLKCJGSxzX7NvEFbLvhjDV0thc91c 35PkjUrmJTrTYoh5F6eZfZm1BHk1vwHzq5+E6roRF+sll1Hiwso1/8ZeLfifoHhq 4vUxYodSFJ9Hq6FOHTltkSQ8oakWHCwbI4+gySKd/PbHWiwkDdiPD2IPvWr2PXqb zlCh4Fl+CYUYQQGU1CTGNmn8jpSzjuxkD/i2v173vxmayLKw== Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wjxassed2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 01 Mar 2024 15:45:53 -0800 (PST) Received: by mail-il1-f198.google.com with SMTP id e9e14a558f8ab-36527824ab9so29020685ab.1 for ; Fri, 01 Mar 2024 15:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1709336753; x=1709941553; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=XzvPtRKbKVvFa1jZ10TJNKD8tfofb346+bik9j68JvU=; b=DQ6LZpgvWb98Ed2EGI2i5i/dfanWEw9B2kWDBkQnLbP3bVqBKGBHAIbHuCEPbP6Sxn ylXl6KGBGQj288t1zCvsg1x/+u3IAMG2lo/h3Q2Nswj3tF1GMwNgo5DQW7xZ1nnxPOQx HVe4z7VhnbQmG4Zt+JBeiQFLEIWnC48TEL2lvKh7Mg4N3bJ3pzL2/awqxNjYWft6mnMF hkmcEfvQXvZyPSryYBmz3RxVkjJVxL4rizg5uxLQIJAaB5f4lYGZZEFy0+PtQLmqNONe VM4KEgevlmoavg/Z7KTlLjVPyiH6UpF6k05gU/nZgjf1YL4iAsXdj+CY/eL/NwHSLUVh Rw7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709336753; x=1709941553; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XzvPtRKbKVvFa1jZ10TJNKD8tfofb346+bik9j68JvU=; b=f+87n43FG6DhJHt2se1qvSYFS32UiFA30yigOSkXXnXLpiIKD6ox6jo/3Xg9oY5bJm /UTEQsFkxFCPZjaKfxJFK+S1oOgDN46jHRMVfe+9L4Vi3Zm4AZF/hzl5Lcjr+d41ODl2 l9VevdNDFboxpBKFEiPgVYMWEU9iCPVpoM2LUO2z8sxqdSLeonkWC0wfOS+wRE/up2e5 Sq1CN768v5UsRAvlLCEq7xPJPny+71akX5AOlCnmOXCYR2RtEbfgySsMV19DsObqnc1T Wi55yLjPIQJogZtqk84l++KbvGYWehq7C3mG4yYwKrcvQgg8hs9JoZH781dM2fOYF2wP X5YA== X-Gm-Message-State: AOJu0YzJhBgNU5ahA5SleBwdNPigC4C/3SKLtsb6kDKv3vzeUN8am2YK FrlxY0112QIbpv++mkpBgF0tnH5aEPpCDqUADBvJSDQPvE5b+nSfqeazdfv/1ysSbk6mpL2dpub OBQIg5C6IZFw3X7zTKnnLXaVr8UfpIUmr6EpqcyipSb2SixL2u3cccJ+87Jg+frja3aRQA+nWBZ QJJZqik69y5G5VdO8j9R+oJbWM/lOmGNdkj+THqvx3PrXBQGM= X-Received: by 2002:a05:6e02:198d:b0:365:def:c5cb with SMTP id g13-20020a056e02198d00b003650defc5cbmr3378043ilf.30.1709336752862; Fri, 01 Mar 2024 15:45:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP4xQH89Jy/pD/5NuTXgXRTesZMNOGFHzODTOvN2xQLusknbM0+KFBjmffaMCFxFKL35UyyQ== X-Received: by 2002:a05:6e02:198d:b0:365:def:c5cb with SMTP id g13-20020a056e02198d00b003650defc5cbmr3378023ilf.30.1709336752290; Fri, 01 Mar 2024 15:45:52 -0800 (PST) Received: from cs-1zgl0npt-heavy-homedir-303475.corp.robot.car (122.32.128.34.bc.googleusercontent.com. [34.128.32.122]) by smtp.gmail.com with ESMTPSA id c6-20020a92cf06000000b00365bd7f608esm1137012ilo.40.2024.03.01.15.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 15:45:51 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v4 4/4] qmi: Enable QRTR service writes and reads Date: Fri, 1 Mar 2024 17:45:35 -0600 Message-ID: <20240301234539.1581017-4-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240301234539.1581017-1-steve.schrock@getcruise.com> References: <20240301234539.1581017-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 2viRLVXVLwTMNLsVwTbgZcwIdvFRJ_fg X-Proofpoint-GUID: 2viRLVXVLwTMNLsVwTbgZcwIdvFRJ_fg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-01_22,2024-03-01_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 bulkscore=0 mlxscore=0 clxscore=1015 phishscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2403010195 For simplicity the QRTR write method simply skips the QMUX header. In the future it might make sense to add another ops function that would allocate a larger buffer and populate the QMUX header in the QMUX implementation. --- drivers/qmimodem/qmi.c | 119 +++++++++++++++++++++++++++++++++-------- 1 file changed, 98 insertions(+), 21 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 570d9bfd..0af402eb 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -62,7 +62,7 @@ struct qmi_service_info { struct qmi_request { uint16_t tid; unsigned int group_id; /* Always 0 for control */ - uint8_t client; + uint8_t client; /* Always 0 for control and qrtr */ struct qmi_service_info info; /* Not used for control requests */ qmi_message_func_t callback; void *user_data; @@ -216,7 +216,7 @@ static void __qmi_service_appeared(struct qmi_device *device, l_memdup(info, sizeof(struct qmi_service_info))); } -static struct qmi_request *__request_alloc(uint8_t service, +static struct qmi_request *__request_alloc(uint32_t service_type, uint8_t client, uint16_t message, const void *data, uint16_t length, qmi_message_func_t func, @@ -228,7 +228,7 @@ static struct qmi_request *__request_alloc(uint8_t service, uint16_t hdrlen = QMI_MUX_HDR_SIZE; uint16_t msglen; - if (service == QMI_SERVICE_CONTROL) + if (service_type == QMI_SERVICE_CONTROL) hdrlen += QMI_CONTROL_HDR_SIZE; else hdrlen += QMI_SERVICE_HDR_SIZE; @@ -244,7 +244,7 @@ static struct qmi_request *__request_alloc(uint8_t service, hdr->frame = 0x01; hdr->length = L_CPU_TO_LE16(req->len - 1); hdr->flags = 0x00; - hdr->service = service; + hdr->service = service_type; /* qmux service types are 8 bits */ hdr->client = client; msg = (struct qmi_message_hdr *) &req->data[hdrlen]; @@ -654,6 +654,26 @@ static void __qmux_debug_msg(const char dir, const void *buf, size_t len, L_LE16_TO_CPU(hdr->length), function, user_data); } +static void __qrtr_debug_msg(const char dir, const void *buf, size_t len, + uint32_t service_type, + qmi_debug_func_t function, void *user_data) +{ + const struct qmi_service_hdr *srv; + const struct qmi_message_hdr *msg; + uint16_t tid; + + if (!len) + return; + + srv = buf; + msg = buf + QMI_SERVICE_HDR_SIZE; + + tid = L_LE16_TO_CPU(srv->transaction); + + __debug_msg(dir, msg, service_type, srv->type, tid, 0, len, + function, user_data); +} + static void __debug_device(struct qmi_device *device, const char *format, ...) { @@ -762,7 +782,7 @@ static unsigned int service_list_create_hash(uint16_t service_type, } static void handle_indication(struct qmi_device *device, - uint8_t service_type, uint8_t client_id, + uint32_t service_type, uint8_t client_id, uint16_t message, uint16_t length, const void *data) { struct qmi_service *service; @@ -795,7 +815,7 @@ static void handle_indication(struct qmi_device *device, } static void __rx_message(struct qmi_device *device, - uint8_t service_type, uint8_t client_id, + uint32_t service_type, uint8_t client_id, const void *buf) { const struct qmi_service_hdr *service = buf; @@ -1935,6 +1955,43 @@ struct qmi_device_qrtr { struct l_idle *shutdown_idle; }; +static int qmi_device_qrtr_write(struct qmi_device *device, + struct qmi_request *req) +{ + struct sockaddr_qrtr addr; + uint8_t *data; + uint16_t len; + ssize_t bytes_written; + int fd = l_io_get_fd(device->io); + + /* Skip the QMUX header */ + data = req->data + QMI_MUX_HDR_SIZE; + len = req->len - QMI_MUX_HDR_SIZE; + + memset(&addr, 0, sizeof(addr)); /* Ensures internal padding is 0 */ + addr.sq_family = AF_QIPCRTR; + addr.sq_node = req->info.qrtr_node; + addr.sq_port = req->info.qrtr_port; + + bytes_written = sendto(fd, data, len, 0, (struct sockaddr *) &addr, + sizeof(addr)); + if (bytes_written < 0) { + DBG("Failure sending data: %s", strerror(errno)); + return -errno; + } + + l_util_hexdump(false, data, bytes_written, + device->debug_func, device->debug_data); + + __qrtr_debug_msg(' ', data, bytes_written, + req->info.service_type, device->debug_func, + device->debug_data); + + l_queue_push_tail(device->service_queue, req); + + return 0; +} + static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, qmi_debug_func_t function, void *user_data) @@ -1957,10 +2014,10 @@ static void qrtr_debug_ctrl_request(const struct qrtr_ctrl_pkt *packet, function(strbuf, user_data); } -static void qrtr_handle_control_packet(struct qmi_device_qrtr *qrtr, - const struct qrtr_ctrl_pkt *packet) +static void qrtr_received_control_packet(struct qmi_device *device, + const void *buf, size_t len) { - struct qmi_device *device = &qrtr->super; + const struct qrtr_ctrl_pkt *packet = buf; uint32_t cmd; uint32_t type; uint32_t instance; @@ -1968,6 +2025,11 @@ static void qrtr_handle_control_packet(struct qmi_device_qrtr *qrtr, uint32_t node; uint32_t port; + if (len < sizeof(*packet)) { + DBG("qrtr packet is too small"); + return; + } + qrtr_debug_ctrl_request(packet, device->debug_func, device->debug_data); @@ -2013,22 +2075,33 @@ static void qrtr_handle_control_packet(struct qmi_device_qrtr *qrtr, } } -static void qrtr_handle_packet(struct qmi_device_qrtr *qrtr, uint32_t sending_port, - const void *buf, ssize_t len) +static void qrtr_received_service_message(struct qmi_device *device, + uint32_t node, uint32_t port, + const void *buf, size_t len) { - const struct qrtr_ctrl_pkt *packet = buf; + const struct l_queue_entry *entry; + uint32_t service_type = 0; - if (sending_port != QRTR_PORT_CTRL) { - DBG("Receive of service data is not implemented"); - return; + for (entry = l_queue_get_entries(device->service_infos); + entry; entry = entry->next) { + struct qmi_service_info *info = entry->data; + + if (info->qrtr_node == node && info->qrtr_port == port) { + service_type = info->service_type; + break; + } } - if ((unsigned long) len < sizeof(*packet)) { - DBG("qrtr control packet is too small"); + if (!service_type) { + DBG("Received msg from unknown service on node: %d, port: %d", + node, port); return; } - qrtr_handle_control_packet(qrtr, packet); + __qrtr_debug_msg(' ', buf, len, service_type, + device->debug_func, device->debug_data); + + __rx_message(device, service_type, 0, buf); } static bool qrtr_received_data(struct l_io *io, void *user_data) @@ -2042,7 +2115,7 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) addr_size = sizeof(addr); bytes_read = recvfrom(l_io_get_fd(qrtr->super.io), buf, sizeof(buf), 0, (struct sockaddr *) &addr, &addr_size); - DBG("Received %zd bytes from Node: %d Port: 0x%x", bytes_read, + DBG("Received %zd bytes from Node: %d Port: %d", bytes_read, addr.sq_node, addr.sq_port); if (bytes_read < 0) @@ -2051,7 +2124,11 @@ static bool qrtr_received_data(struct l_io *io, void *user_data) l_util_hexdump(true, buf, bytes_read, qrtr->super.debug_func, qrtr->super.debug_data); - qrtr_handle_packet(qrtr, addr.sq_port, buf, bytes_read); + if (addr.sq_port == QRTR_PORT_CTRL) + qrtr_received_control_packet(&qrtr->super, buf, bytes_read); + else + qrtr_received_service_message(&qrtr->super, addr.sq_node, + addr.sq_port, buf, bytes_read); return true; } @@ -2152,7 +2229,7 @@ static void qmi_device_qrtr_destroy(struct qmi_device *device) } static const struct qmi_device_ops qrtr_ops = { - .write = NULL, + .write = qmi_device_qrtr_write, .discover = qmi_device_qrtr_discover, .client_create = NULL, .client_release = NULL,