uk-proxy-kcom.c (1268B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: kcom.c 8 * Purpose: Provides a kcom interface using User/Kernel proxy services 9 */ 10 11 #ifdef INCLUDE_KNET 12 13 #include <sal/appl/io.h> 14 #include <kcom.h> 15 16 #include <linux-uk-proxy.h> 17 #include <uk-proxy-kcom.h> 18 19 static int uk_proxy = -1; 20 21 void * 22 uk_proxy_kcom_open(char *name) 23 { 24 if (uk_proxy < 0) { 25 uk_proxy = linux_uk_proxy_open(); 26 if (uk_proxy < 0) { 27 return NULL; 28 } 29 } 30 return name; 31 } 32 33 int 34 uk_proxy_kcom_close(void *handle) 35 { 36 return 0; 37 } 38 39 int 40 uk_proxy_kcom_msg_send(void *handle, void *msg, 41 unsigned int len, unsigned int bufsz) 42 { 43 if (len > LUK_MAX_DATA_SIZE) { 44 return -1; 45 } 46 return linux_uk_proxy_send(handle, msg, len); 47 } 48 49 int 50 uk_proxy_kcom_msg_recv(void *handle, void *msg, 51 unsigned int bufsz) 52 { 53 unsigned int len; 54 55 if (bufsz > LUK_MAX_DATA_SIZE) { 56 return -1; 57 } 58 len = bufsz; 59 if (linux_uk_proxy_recv(handle, msg, &len) < 0) { 60 return -1; 61 } 62 return len; 63 } 64 65 #endif 66 67 int _uk_proxy_kcom_c_not_empty;