Klein writes that קסם originally meant "to cut, break, divide, distribute" as in Arabic qasama ( = he divided, distributed, apportioned). Jastrow says that a kasam קסם means "a carver", and gives an interesting interpretation to the Mishna and Gemara in Sanhedrin 81b:
והמקלל בקוסם: תני רב יוסף יכה קוסם את קוסמו
This is generally translated as "He who curses by enchantment: He curses thus: 'May the charm [the idol] slay its enchanter' ". However, Jastrow translates it as "He that curses (his neighbor) invoking God as 'a carver' (instead of creator ex nihilo): may the carver strike his carving."
From this meaning, we get the word kesam קיסם, originally meaning "chip, carving" and now meaning "toothpick" as well.
Klein continues his etymology as follows:
'he divided by drawing lots at the sanctuary', istaqsama ( =he got a part allotted to himself), aqsama (= he swore), qismah (=portion, lot, fate), whence Turkish qismet
This is also the source of the English word kismet.
From the meaning of קסם as divination, enchantment, magic, we get the Hebrew adjective maksim מקסים - which means enchanting, and has nothing to do with "maxim" or "maximum".
One little story related to the two meanings of קסם: When I first went to the well known Jerusalem restaurant Marvad HaKesamim I wasn't aware of the significance of the name. (It means "magic carpet", and was also the name of the operation that brought Yemenite Jews to Israel at the founding of the state.) At the end of the meal, they served us toothpicks, which only then I learned were called "keisamim". I couldn't understand why they'd name a restaurant after toothpicks, even of the highest quality...